We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
For example:
aExpr <- &('-' number) stateChange '-' number { c.globalState["code"].push(vmCode(typeUnaryMinus)) } stateChange <- #{ c.globalState['minus'] += 1 } number <- [0-9]+ { c.globalState["code"].push(newIntVal(c.text)); }
Many script languages are not generate ast, instead of write code directly.
In this example, i want to check if - number is matched, then make state change.
- number
But c.globalState["code"].push(newIntVal(c.text)) is invoked while looking ahead of "- number". I think it could use some improvement.
c.globalState["code"].push(newIntVal(c.text))
There's a simple patch:
// edit parseAndExpr: func (p *parser) parseAndExpr(and *andExpr) (any, bool) { pt := p.pt state := p.cloneState() p.pushV() p.cur.state["skipCode"] = true _, ok := p.parseExprWrap(and.expr) delete(p.cur.state, "skipCode") p.popV() p.restoreState(state) p.restore(pt) return nil, ok } // edit parseActionExpr: func (p *parser) parseActionExpr(act *actionExpr) (any, bool) { if p.cur.state["skipCode"] == true { return nil, true } start := p.pt val, ok := p.parseExprWrap(act.expr) if ok { ..... }
Do same thing to parseOrExpr and other codeExpr.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
For example:
Many script languages are not generate ast, instead of write code directly.
In this example, i want to check if
- number
is matched, then make state change.But
c.globalState["code"].push(newIntVal(c.text))
is invoked while looking ahead of "- number". I think it could use some improvement.There's a simple patch:
Do same thing to parseOrExpr and other codeExpr.
The text was updated successfully, but these errors were encountered: