Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add include_file #57

Open
dlurton opened this issue Dec 10, 2020 · 2 comments
Open

Add include_file #57

dlurton opened this issue Dec 10, 2020 · 2 comments
Assignees

Comments

@dlurton
Copy link
Member

dlurton commented Dec 10, 2020

Given a file: universe_a.ion, with contents:

// universe_a.ion:
(define toy_lang (domain ... ))

And another file universe_b.ion that resides in a different directory, I should be able to include the universe_a.ion file in universe_b.ion.

We might find a need to make this more sophisticated in the future, but to keep this simple for now, the result will be the same as if the (include_file ...) statement were replaced with the contents of universe_a.ion:

// universe_b.ion:

(include_file "universe_a.ion")

// now domains defined in universe_a.ion are available for permutation

(define permuted_domain 
       (permute_domain toy_lang ...))

The grammar of the include_file statement is:

include_file_stmt :== '(' 'include_file' <string> ')'

Other requirements (not in any order):

  • Attempts to include the same file twice should be ignored, thereby preventing cyclic includes.
  • After all of the include_file statements in all included files have been processed, the result should be a single type universe with all of the domains from all of the included files, which can then be passed through the remaining processing steps that exist today. No changes to those processing steps are needed.
  • Since we're now dealing with multiple files, we must include the path to the file containing the error in any error messages produced by pig. We currently use IonElement's IonLocation meta for this, but it lacks a property for the filename. The filename should either be specified in a different meta, or a new meta should be used that has properties for the source file, line and character offset.
  • When error information including the source file, line, column & message is output to the console, the format should be: <relative-path-to-ion-file>:<line>:<column>: <message> This format is understood by certain IDEs such as Visual Studio and IntelliJ (with a plugin) and causes the IDE to to turn the location text in the console output into a clickable hyperlink. (A quality of life improvement.)
@rhinomode
Copy link

Without this feature (or discussion of its future), I do not see how this will work in the long term.

Use-case: I want to directly support the some expressions defined by the partiql_ast for my own domain (using permute_domain). Without this feature I copy-paste the entire contents of partiql_ast.ion into my own .ion file.

@dlurton dlurton changed the title include An import statement Dec 19, 2020
dlurton added a commit that referenced this issue May 14, 2021
@dlurton dlurton self-assigned this May 14, 2021
@dlurton dlurton changed the title An import statement Add include_file Jun 15, 2021
@dlurton
Copy link
Member Author

dlurton commented Jun 15, 2021

Amended the title and description of this issue by replacing the term "import" with "include" to reflect this decision that was made during the review of #74.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants