public override IList <SrcOp> Wildcard(GrammarAST ast, GrammarAST labelAST) { Wildcard wild = new Wildcard(this, ast); // TODO: dup with tokenRef if (labelAST != null) { string label = labelAST.Text; Decl d = GetTokenLabelDecl(label); wild.labels.Add(d); GetCurrentRuleFunction().AddContextDecl(ast.GetAltLabel(), d); if (labelAST.Parent.Type == ANTLRParser.PLUS_ASSIGN) { TokenListDecl l = GetTokenListLabelDecl(label); GetCurrentRuleFunction().AddContextDecl(ast.GetAltLabel(), l); } } if (controller.NeedsImplicitLabel(ast, wild)) { DefineImplicitLabel(ast, wild); } AddToLabelList listLabelOp = GetAddToListOpIfListLabelPresent(wild, labelAST); return(List(wild, listLabelOp)); }
public virtual AddToLabelList GetAddToListOpIfListLabelPresent(LabeledOp op, GrammarAST label) { AddToLabelList labelOp = null; if (label != null && label.Parent.Type == ANTLRParser.PLUS_ASSIGN) { string listLabel = GetTarget().GetListLabel(label.Text); labelOp = new AddToLabelList(this, listLabel, op.GetLabels()[0]); } return(labelOp); }
public override IList <SrcOp> RuleRef(GrammarAST ID, GrammarAST label, GrammarAST args) { InvokeRule invokeOp = new InvokeRule(this, ID, label); // If no manual label and action refs as token/rule not label, we need to define implicit label if (controller.NeedsImplicitLabel(ID, invokeOp)) { DefineImplicitLabel(ID, invokeOp); } AddToLabelList listLabelOp = GetAddToListOpIfListLabelPresent(invokeOp, label); return(List(invokeOp, listLabelOp)); }
public override IList <SrcOp> TokenRef(GrammarAST ID, GrammarAST labelAST, GrammarAST args) { MatchToken matchOp = new MatchToken(this, (TerminalAST)ID); if (labelAST != null) { string label = labelAST.Text; RuleFunction rf = GetCurrentRuleFunction(); if (labelAST.Parent.Type == ANTLRParser.PLUS_ASSIGN) { // add Token _X and List<Token> X decls DefineImplicitLabel(ID, matchOp); // adds _X TokenListDecl l = GetTokenListLabelDecl(label); rf.AddContextDecl(ID.GetAltLabel(), l); } else { Decl d = GetTokenLabelDecl(label); matchOp.labels.Add(d); rf.AddContextDecl(ID.GetAltLabel(), d); } // Decl d = getTokenLabelDecl(label); // ((MatchToken)matchOp).labels.add(d); // getCurrentRuleFunction().addContextDecl(ID.getAltLabel(), d); // if ( labelAST.parent.getType() == ANTLRParser.PLUS_ASSIGN ) { // TokenListDecl l = getTokenListLabelDecl(label); // getCurrentRuleFunction().addContextDecl(ID.getAltLabel(), l); // } } if (controller.NeedsImplicitLabel(ID, matchOp)) { DefineImplicitLabel(ID, matchOp); } AddToLabelList listLabelOp = GetAddToListOpIfListLabelPresent(matchOp, labelAST); return(List(matchOp, listLabelOp)); }
public override IList <SrcOp> Set(GrammarAST setAST, GrammarAST labelAST, bool invert) { MatchSet matchOp; if (invert) { matchOp = new MatchNotSet(this, setAST); } else { matchOp = new MatchSet(this, setAST); } if (labelAST != null) { string label = labelAST.Text; RuleFunction rf = GetCurrentRuleFunction(); if (labelAST.Parent.Type == ANTLRParser.PLUS_ASSIGN) { DefineImplicitLabel(setAST, matchOp); TokenListDecl l = GetTokenListLabelDecl(label); rf.AddContextDecl(setAST.GetAltLabel(), l); } else { Decl d = GetTokenLabelDecl(label); matchOp.labels.Add(d); rf.AddContextDecl(setAST.GetAltLabel(), d); } } if (controller.NeedsImplicitLabel(setAST, matchOp)) { DefineImplicitLabel(setAST, matchOp); } AddToLabelList listLabelOp = GetAddToListOpIfListLabelPresent(matchOp, labelAST); return(List(matchOp, listLabelOp)); }