public SemPred(OutputModelFactory factory, [NotNull] ActionAST ast) : base(factory, ast) { Debug.Assert(ast.atnState != null && ast.atnState.NumberOfTransitions == 1 && ast.atnState.Transition(0) is AbstractPredicateTransition); GrammarAST failNode = ast.GetOptionAST("fail"); predicate = ast.Text; if (predicate.StartsWith("{") && predicate.EndsWith("}?")) { predicate = predicate.Substring(1, predicate.Length - 3); } predicate = factory.GetTarget().GetTargetStringLiteralFromString(predicate); if (failNode == null) return; if (failNode is ActionAST) { ActionAST failActionNode = (ActionAST)failNode; RuleFunction rf = factory.GetCurrentRuleFunction(); failChunks = ActionTranslator.TranslateAction(factory, rf, failActionNode.Token, failActionNode); } else { msg = factory.GetTarget().GetTargetStringLiteralFromANTLRStringLiteral(factory.GetGenerator(), failNode.Text, true); } }
protected SrcOp(OutputModelFactory factory, GrammarAST ast) : base(factory, ast) { if (ast != null) uniqueID = ast.Token.TokenIndex; enclosingBlock = factory.GetCurrentBlock(); enclosingRuleRunction = factory.GetCurrentRuleFunction(); }
protected SrcOp(OutputModelFactory factory, GrammarAST ast) : base(factory, ast) { if (ast != null) { uniqueID = ast.Token.TokenIndex; } enclosingBlock = factory.GetCurrentBlock(); enclosingRuleRunction = factory.GetCurrentRuleFunction(); }
public MatchSet(OutputModelFactory factory, GrammarAST ast) : base(factory, ast) { SetTransition st = (SetTransition)ast.atnState.Transition(0); int wordSize = factory.GetGenerator().GetTarget().GetInlineTestSetWordSize(); expr = new TestSetInline(factory, null, st.set, wordSize); Decl.Decl d = new TokenTypeDecl(factory, expr.varName); factory.GetCurrentRuleFunction().AddLocalDecl(d); capture = new CaptureNextTokenType(factory, expr.varName); }
public Action(OutputModelFactory factory, ActionAST ast) : base(factory, ast) { RuleFunction rf = factory.GetCurrentRuleFunction(); if (ast != null) { chunks = ActionTranslator.TranslateAction(factory, rf, ast.Token, ast); } else { chunks = new List<ActionChunk>(); } //System.out.println("actions="+chunks); }
public Action(OutputModelFactory factory, ActionAST ast) : base(factory, ast) { RuleFunction rf = factory.GetCurrentRuleFunction(); if (ast != null) { chunks = ActionTranslator.TranslateAction(factory, rf, ast.Token, ast); } else { chunks = new List <ActionChunk>(); } //System.out.println("actions="+chunks); }
public Action(OutputModelFactory factory, StructDecl ctx, string action) : base(factory, null) { ActionAST ast = new ActionAST(new CommonToken(ANTLRParser.ACTION, action)); RuleFunction rf = factory.GetCurrentRuleFunction(); if (rf != null) { // we can translate ast.resolver = rf.rule; chunks = ActionTranslator.TranslateActionChunk(factory, rf, action, ast); } else { chunks = new List<ActionChunk>(); chunks.Add(new ActionText(ctx, action)); } }
public Action(OutputModelFactory factory, StructDecl ctx, string action) : base(factory, null) { ActionAST ast = new ActionAST(new CommonToken(ANTLRParser.ACTION, action)); RuleFunction rf = factory.GetCurrentRuleFunction(); if (rf != null) { // we can translate ast.resolver = rf.rule; chunks = ActionTranslator.TranslateActionChunk(factory, rf, action, ast); } else { chunks = new List <ActionChunk>(); chunks.Add(new ActionText(ctx, action)); } }
public SemPred(OutputModelFactory factory, [NotNull] ActionAST ast) : base(factory, ast) { Debug.Assert(ast.atnState != null && ast.atnState.NumberOfTransitions == 1 && ast.atnState.Transition(0) is AbstractPredicateTransition); GrammarAST failNode = ast.GetOptionAST("fail"); predicate = ast.Text; if (predicate.StartsWith("{") && predicate.EndsWith("}?")) { predicate = predicate.Substring(1, predicate.Length - 3); } predicate = factory.GetTarget().GetTargetStringLiteralFromString(predicate); if (failNode == null) { return; } if (failNode is ActionAST) { ActionAST failActionNode = (ActionAST)failNode; RuleFunction rf = factory.GetCurrentRuleFunction(); failChunks = ActionTranslator.TranslateAction(factory, rf, failActionNode.Token, failActionNode); } else { msg = factory.GetTarget().GetTargetStringLiteralFromANTLRStringLiteral(factory.GetGenerator(), failNode.Text, true); } }