Skip to content
This repository has been archived by the owner on Jan 24, 2020. It is now read-only.

Create version of AST for each version of Lua #18

Open
LPGhatguy opened this issue Apr 24, 2018 · 1 comment
Open

Create version of AST for each version of Lua #18

LPGhatguy opened this issue Apr 24, 2018 · 1 comment
Labels
enhancement New feature or request

Comments

@LPGhatguy
Copy link
Owner

It should be possible to validate that the given AST is valid for a given version of Lua by casting between ASTs.

For example:

let ast = parse(source);
let ast_5_1 = ast.to_version_5_1().expect("Source was not valid Lua 5.1! (maybe it used goto?)");
let new_ast = ast_5_1.to_version_agnostic(); // What do we call this?

assert_eq!(ast, new_ast);
@LPGhatguy LPGhatguy added the enhancement New feature or request label Apr 24, 2018
@LPGhatguy
Copy link
Owner Author

The alternative to this would be to keep every version of Lua using the same AST types, but just have validation functions to check for features you can't use in your target version.

Then we might be able to avoid the maintenance hell of trying to keep all these ASTs in sync at the expense of version-specific tools having to verify that the AST doesn't contain unknown nodes.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant