-
Notifications
You must be signed in to change notification settings - Fork 28
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
Implement named references #41
Conversation
lib/lrama/lexer.rb
Outdated
@@ -257,6 +288,9 @@ def lex_user_code(ss, line, column, lines) | |||
when ss.scan(/\$(<[a-zA-Z0-9_]+>)?(\d+)/) # $1, $2, $<long>1 | |||
tag = ss[1] ? create_token(Token::Tag, ss[1], line, str.length) : nil | |||
references << [:dollar, Integer(ss[2]), tag, str.length, str.length + ss[0].length - 1] | |||
when ss.scan(/\$(<[a-zA-Z0-9_]+>)?([a-zA-Z0-9_]+)/) # $foo, $expr, $<long>program |
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 guess the second capture ([a-zA-Z0-9_]+
) might be same with the capture for Token::Named_Ref
except for []
(so that [a-zA-Z_.][-a-zA-Z0-9_.]*
).
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.
Sorry, exactly saying ...
It might be same with one of two:
Token::Ident
([a-zA-Z_.][-a-zA-Z0-9_.]*
)Token::Named_Ref
except for[]
(so that[a-zA-Z_.][-a-zA-Z0-9_.]*
)
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.
Thank you for reviewing. Is this the change you were suggesting?
3b8d4e5#diff-816037370d9ebaadd970a429ac66cdf5597623e3f285642396489c85b05b89c5R266
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.
Yes, if you have concerns, please let me know :)
88a6e7b
to
811164f
Compare
Thanks for your PR, I left a comment. Other seems good. |
811164f
to
faa4225
Compare
Thank you!! |
Summary
In this pull request, I have implemented the Named References concept from bison.
By merging this pull request, it will be possible to refer to the value by its symbol in the rule or its alias from within the action.
Changes made