Merge pull request #2047 from bramp/commonsetstuff

[Go] Placed the CommonSetStuff code inside a scope
This commit is contained in:
Terence Parr 2017-10-12 09:42:32 -07:00 committed by GitHub
commit 8778ad65c4
1 changed files with 22 additions and 20 deletions

View File

@ -777,29 +777,31 @@ MatchSet(m, expr, capture) ::= "<CommonSetStuff(m, expr, capture, false)>"
MatchNotSet(m, expr, capture) ::= "<CommonSetStuff(m, expr, capture, true)>"
CommonSetStuff(m, expr, capture, invert) ::= <<
p.SetState(<m.stateNumber>)
<if(m.labels)>
var _lt = p.GetTokenStream().LT(1)<! TODO: Should LT be called always like InvokeRule and MatchToken? !>
<m.labels:{l | <labelref(l)> = _lt}; separator="\n">
<endif>
<if(capture)>
<capture>
<endif>
<if(invert)>if <m.varName> \<= 0 || <expr> <else>if !(<expr>)<endif> {
{
p.SetState(<m.stateNumber>)
<if(m.labels)>
var _ri = p.GetErrorHandler().RecoverInline(p)
<m.labels:{l | <labelref(l)> = _ri}; separator="\n">
<else>
p.GetErrorHandler().RecoverInline(p)
var _lt = p.GetTokenStream().LT(1)<! TODO: Should LT be called always like InvokeRule and MatchToken? !>
<m.labels:{l | <labelref(l)> = _lt}; separator="\n">
<endif>
} else {
p.GetErrorHandler().ReportMatch(p)
p.Consume()
<if(capture)>
<capture>
<endif>
<if(invert)>if <m.varName> \<= 0 || <expr> <else>if !(<expr>)<endif> {
<if(m.labels)>
var _ri = p.GetErrorHandler().RecoverInline(p)
<m.labels:{l | <labelref(l)> = _ri}; separator="\n">
<else>
p.GetErrorHandler().RecoverInline(p)
<endif>
} else {
p.GetErrorHandler().ReportMatch(p)
p.Consume()
}
}
>>