Esempio n. 1
0
 public NonLocalAttrRef(StructDecl ctx, string ruleName, string name, int ruleIndex)
     : base(ctx)
 {
     this.name = name;
     this.ruleName = ruleName;
     this.ruleIndex = ruleIndex;
 }
Esempio n. 2
0
 public SetNonLocalAttr(StructDecl ctx,
                        string ruleName, string name, int ruleIndex,
                        IList<ActionChunk> rhsChunks)
         : base(ctx, name, rhsChunks)
 {
     this.ruleName = ruleName;
     this.ruleIndex = ruleIndex;
 }
Esempio n. 3
0
 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));
     }
 }
Esempio n. 4
0
 public RulePropertyRef_text(StructDecl ctx, string label)
     : base(ctx, label)
 {
 }
Esempio n. 5
0
 public LabelRef(StructDecl ctx, string name)
     : base(ctx)
 {
     this.name = name;
 }
Esempio n. 6
0
 public ActionText(StructDecl ctx, string text)
     : base(ctx)
 {
     this.text = text;
 }
Esempio n. 7
0
 public Action(OutputModelFactory factory, StructDecl ctx, Template actionST)
     : base(factory, null)
 {
     chunks = new List<ActionChunk>();
     chunks.Add(new ActionTemplate(ctx, actionST));
 }
Esempio n. 8
0
        public RuleFunction(OutputModelFactory factory, Rule r)
            : base(factory)
        {
            this.name = r.name;
            this.rule = r;
            if (r.modifiers != null && r.modifiers.Count > 0)
            {
                this.modifiers = new List<string>();
                foreach (GrammarAST t in r.modifiers)
                    modifiers.Add(t.Text);
            }
            modifiers = Utils.NodesToStrings(r.modifiers);

            index = r.index;
            int lfIndex = name.IndexOf(ATNSimulator.RuleVariantDelimiter);
            if (lfIndex >= 0)
            {
                variantOf = name.Substring(0, lfIndex);
            }

            if (r.name.Equals(r.GetBaseContext()))
            {
                ruleCtx = new StructDecl(factory, r);
                AddContextGetters(factory, r.g.contextASTs[r.name]);

                if (r.args != null)
                {
                    ICollection<Attribute> decls = r.args.attributes.Values;
                    if (decls.Count > 0)
                    {
                        args = new List<AttributeDecl>();
                        ruleCtx.AddDecls(decls);
                        foreach (Attribute a in decls)
                        {
                            args.Add(new AttributeDecl(factory, a));
                        }
                        ruleCtx.ctorAttrs = args;
                    }
                }
                if (r.retvals != null)
                {
                    ruleCtx.AddDecls(r.retvals.attributes.Values);
                }
                if (r.locals != null)
                {
                    ruleCtx.AddDecls(r.locals.attributes.Values);
                }
            }
            else
            {
                if (r.args != null || r.retvals != null || r.locals != null)
                {
                    throw new System.NotSupportedException("customized fields are not yet supported for customized context objects");
                }
            }

            ruleLabels = r.GetElementLabelNames();
            tokenLabels = r.GetTokenRefs();
            if (r.exceptions != null)
            {
                exceptions = new List<ExceptionClause>();
                foreach (GrammarAST e in r.exceptions)
                {
                    ActionAST catchArg = (ActionAST)e.GetChild(0);
                    ActionAST catchAction = (ActionAST)e.GetChild(1);
                    exceptions.Add(new ExceptionClause(factory, catchArg, catchAction));
                }
            }

            startState = factory.GetGrammar().atn.ruleToStartState[r.index];
        }
Esempio n. 9
0
 public QRetValueRef(StructDecl ctx, string dict, string name)
     : base(ctx, name)
 {
     this.dict = dict;
 }
Esempio n. 10
0
 public ArgRef(StructDecl ctx, string name)
     : base(ctx, name)
 {
 }
Esempio n. 11
0
 public ListLabelRef(StructDecl ctx, string name)
     : base(ctx, name)
 {
 }
Esempio n. 12
0
 public TokenRef(StructDecl ctx, string name)
     : base(ctx)
 {
     this.name = name;
 }
Esempio n. 13
0
 public SetAttr(StructDecl ctx, string name, IList<ActionChunk> rhsChunks)
     : base(ctx)
 {
     this.name = name;
     this.rhsChunks = rhsChunks;
 }
Esempio n. 14
0
 public RetValueRef(StructDecl ctx, string name)
     : base(ctx)
 {
     this.name = name;
 }
Esempio n. 15
0
 public TokenPropertyRef_int(StructDecl ctx, string label)
     : base(ctx, label)
 {
 }
Esempio n. 16
0
 public TokenPropertyRef(StructDecl ctx, string label)
     : base(ctx)
 {
     this.label = label;
 }
Esempio n. 17
0
 public ActionTemplate(StructDecl ctx, Template st)
     : base(ctx)
 {
     this.st = st;
 }
 public ThisRulePropertyRef_start(StructDecl ctx, string label)
     : base(ctx, label)
 {
 }
Esempio n. 19
0
 public ActionChunk(StructDecl ctx)
 {
     this.ctx = ctx;
 }