-
Notifications
You must be signed in to change notification settings - Fork 122
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
Validation #49
Comments
Maybe the validation should work on Flow AST? |
@iddan Could you provide more information what do you have in mind? |
If the pipeline is:
Then we can replace the
This will reduce the scope that Walt has to deal with and allow any valid JS/Flow syntax in the AST level |
So you propose that we move from our custom parser and tokenizer to |
Exactly as the tokens and syntax is the same only the meaning of them change |
I think once the project is mature and stable enough something like that should be possible. Right now I'd like to keep the discussion focused on implementing the changes outlined in the issue. |
I've unblocked this with #56 and implemented a basic validation step. |
Goal
Make it easier to extend the syntax and make compiler easier to work with.
Overview
This should unblock #28
Currently, the individual node parsing methods perform in-place validation on the syntax. For example, the identifier parser may throw an undefined variable syntax error if it cannot identify the variable.
walt/src/parser/maybe-identifier.js
Line 48 in 296f1cb
This is OK, but the more syntax is extended the harder it is to extend the behavior. In the above code, the undefined variable handler is overwritten to silence the error while parsing function arguments(while parsing the parent node). Instead of doing the above, let's have another step before the generator, a static type/validator checker.
The final pipeline will look like this:
Tokenizer -> tokens -> Parser -> ast -> Static Checker -> ast/dag -> Generator -> ir -> Emitter -> bytecode
Initial implementation would only handle
Identifier
nodes. This means the static checker would do the following:The text was updated successfully, but these errors were encountered: