-
-
Notifications
You must be signed in to change notification settings - Fork 174
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
Disable EQUS
expansion for raw symbols (by lexing them as strings)
#1649
Conversation
EQUS
expansion for raw symbols ("the lexer approach")EQUS
expansion for raw symbols (by lexing them as strings)
5104a5e
to
fa6c463
Compare
What feels natural to me about this:
The downsides:
|
Re: comparisons to the C lexer hack, Wikipedia claims:
This "modern" approach sounds similar to the one used in the other PR, #1648. |
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.
The spirit of this PR looks good to me, I think I only have bikeshedding-level changes to request. Thanks!
.Dq raw symbol | ||
prefixed by a hash | ||
.Sq # . |
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 this should be more explicit that “raw symbol” means “prefixed with a hash”.
I'm also realising that “raw identifier” is a better name, since it might not be referring to a symbol yet? (And identifiers are names for symbols. I'd be fine with calling those “raw names”, if that sounds better than “identifier”.)
Expansion is also disabled for raw string constant symbols (string constant symbols prefixed by a hash | ||
.Sq # ) . |
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.
In the vein of my previous comment:
Expansion is also disabled for raw string constant symbols (string constant symbols prefixed by a hash | |
.Sq # ) . | |
Also, expansion is | |
.Sy not | |
performed if the string symbol's name is preceded by a hash | |
.Sq # . |
@@ -1,7 +1,7 @@ | |||
error: def-scoped.asm(10): | |||
syntax error, unexpected local label, expecting symbol | |||
syntax error, unexpected local label, expecting symbol or string symbol |
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.
Hmm... this sounds confusing. “Why is it expecting a symbol or a symbol?”
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.
Yeah, this is one reason why I prefer #1648 as well.
Fixes #1605
The goal here is to make
#raw
string symbols get treated like string literals/expressions instead of gettingEQUS
-expanded. The long-term goal is to implement that in a way compatible with removingEQUS
expansion for all symbols (#905).This approach works by just adding a new
SYM_ID
token type, and lexing raw identifiers which would otherwise have beenEQUS
-expanded asSYM_ID
tokens instead. Then the parser has to treat this token type as a string in the right contexts. So now, in addition to therelocexpr_no_str
distinction, it needs ascoped_anon_id_no_str
distinction.This PR needs further comparison with the alternative parser-based approach implemented in #1648.