Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
MatchOr and guard statements #158
base: main
Are you sure you want to change the base?
MatchOr and guard statements #158
Changes from 21 commits
77da54b
c213d0f
73425a6
adb9a50
f64490e
4aa1195
607c359
33f7439
a57b6a8
e1d90f9
64a281c
4ab48e8
2dbcf03
62a4633
fc0372a
ad11197
5b6e676
0a55289
f300ee7
c047696
3b78dd7
fc4eca9
1a1cefe
befd6dc
efd60f8
7b67262
33327a3
587c50b
ee82180
4db2356
ccb0c5d
2d5807e
fd2ddee
0daeb72
3cf0b0e
2019d4b
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Weird hack, might cause issues if there's an actual$\LaTeX$ code.
subject_name
in theThere 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.
Yes that is something we considered as well and would love to hear suggestions.
Since each of the visit_Match... functions cannot access the subject_latex variable(each of those functions can only have the ast node and pattern as the input), we had to find a workaround. We tried to use python format and % to insert the subject_latex but the use of % and {} in latex made this very difficult. Do you have any suggestions for how to better implement this (or possible a better name than "subject_name" to replace)
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.
Ah yeah I see the dilemma, bit perplexing lol. Not entirely sure how to solve but I'll give it some thought. Thanks for tackling
match
statements btw! Really cool feature :)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.
Not sure what @odashi thinks of this solution, but you could create a stack of
_match_subject_stack: list[str] = []
, and at the very beginning ofvisit_Match
do something likeand then right before you return do something like
and you would also have
A stack is only required if nested match statements is supported, which it seems like it is, although I have no idea if it's valid$\LaTeX$ output? In any case this situation I think necessitates a test for nested match statements (assuming they're supported), in order to test that in
visit_MatchValue
, the LHS takes the appropriate_subject_latex
, i.e. the inner one should take the innersubject
while the outer one takes the outer.edit:
_subject_latexes
->_match_subject_stack
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.
I think the @ZibingZhang 's solution is desirable at this point.
One minor point is that the private member
_subject_latexes
sounds weird for every other visitors, more specific name (like_match_subject_stack
) would be better.