-
Notifications
You must be signed in to change notification settings - Fork 182
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
Add code:yytarget_elem to syntax files. #537
base: master
Are you sure you want to change the base?
Conversation
b5c7d5b
to
eb98c66
Compare
Should I make another syntax variable for relative gotos as well i.e. |
code:yytarget_elem specifies the how the table elements for computed goto tables are generated. If cgoto:relative = 1, then the table entries contain an offset from a calculated base address. Bootstrap code has been regenerate.
eb98c66
to
dfe47cc
Compare
You mean another syntax configuration for the goto statement that uses table elements? Yes please. Something like |
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.
Thanks! Looks good overall, just a few suggestions how to polish it.
@@ -441,3 +441,5 @@ code:yylessthan = | |||
code:yybm_filter = yych " & ~0xFF"; | |||
|
|||
code:yybm_match = yybm "[" offset "+" yych "] & " mask; | |||
|
|||
code:yytarget_elem = (.cgoto.relative ? "(int)((char*)&&" : "&&") label (.cgoto.relative ? " - (char*)&&" base ")"); |
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 it will be a bit cleaner if you totally split the two cases, like this:
code:yytarget_elem = (.cgoto.relative
? "(int)((char*)&&" label " - (char*)&&" base ")"
: "&&" label);
@@ -177,6 +177,27 @@ class GenEnumElem : public RenderCallback { | |||
FORBID_COPY(GenEnumElem); | |||
}; | |||
|
|||
class GenYytargetElem : public RenderCallback { |
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.
Just GenTargetElem
to match the rest of the names that don't have YY
.
case StxVarId::BASE: os << base; break; | ||
case StxVarId::LABEL: os << label; break; |
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.
Formatting: in a simple switch where each case fits on one line we do indent cases.
const std::string base = buf.str(prefix).label(base_label).flush(); | ||
const std::string lbl = buf.str(prefix).label(label).flush(); |
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.
Instead of creating these temporary strings with unnecessarily long lifetime, can you save options and label references in GenTargetElem
and output them directly?
Do you mean to have something like:
|
Yes, but please use |
I chose array because the code currently overlaps condition table generation with |
Ah, I see why you chose First, sticking with Second, we can rename What do you think? |
I think the first option could be useful - there's a high chance that when conditions are used, there will be very few conditions, one could in theory set the elem type for conditions as |
Ok, let's go this way. Should we also add |
code:yytarget_elem
specifies the type used for the element types in the computed goto tables.