-
Notifications
You must be signed in to change notification settings - Fork 5
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
Added when keyword #43
base: master
Are you sure you want to change the base?
Conversation
VonTum
commented
Dec 20, 2024
- added when literal to grammar
- updated auto generated tree-sitter configs
- added "is_when" bool to if-struct
- added when literal to grammar - updated auto generated tree-sitter configs - added "is_when" bool to if-struct
Curious, from my first look through parser.c, the massive line count difference is explained by differing tree-sitter versions. Perhaps you're using a slightly newer version of tree-sitter do do your generation? Could you check In general though, you don't need to worry about line changes in parser.c or any of the other generated files. It's usually good practise to have a look at the changes, because tree-sitter generates reasonably readable C code, and I especially just look at the upper header, at STATE_COUNT, LARGE_STATE_COUNT, and others to see if a change I've made drastically messes up the generated parser. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a good start! The parser update looks good, all that is left is to add the necessary warning/error, and make the is_generative
depend on the keyword, instead of the context.
let if_id = self.instructions.alloc(Instruction::IfStatement(IfStatement { | ||
condition, | ||
is_when: literal_is_when, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a little rust trick here, if you rename literal_is_when
to just is_when
, then you can omit the is_when: literal_is_when al-togehter
let if_id = self.instructions.alloc(Instruction::IfStatement(IfStatement { | ||
condition, | ||
is_when: literal_is_when, | ||
is_generative: condition_is_generative,// TODO `if` vs `when` https://github.com/pc2/sus-compiler/issues/3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's TODO's like this one scattered around the codebase. I believe you can get rid of is_generative
when you add the warning inline here. (Or even have is_generative
get the value of literal_is_when
, rather than from its context)