-
Notifications
You must be signed in to change notification settings - Fork 30
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
parsing python like languages #79
Comments
Hello @schneidersoft, the indentation is just another character for the parser, so there is not much different to other parsers. You can also use references to make sure the indentation on each line is correct (at least in simple cases, more complex code would probably need to check this in code). Here is a very simple grammar to parse python-like function definition:
It would report syntax error if you run it on incorrectly indented code. |
PS: Here is a full python grammar (just in slightly different format than the one used by PackCC), if you need some inspiration: https://docs.python.org/3/reference/grammar.html |
Right. I was wondering how to integrate a tokenizer that would produce the INDENT end DEDENT tokens packcc would then be able to use. |
Look here https://github.com/exaloop/codon/blob/develop/codon/parser/peg/grammar.peg how it uses https://github.com/yhirose/cpp-peglib to parse a Python like language. |
How would I parse python like languages where indentation is used to handle scope?
The text was updated successfully, but these errors were encountered: