Ejemplo n.º 1
0
 public NonLocalAttrRef(StructDecl ctx, string ruleName, string name, int ruleIndex)
     : base(ctx)
 {
     this.name = name;
     this.ruleName = ruleName;
     this.ruleIndex = ruleIndex;
 }
Ejemplo 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;
 }
Ejemplo 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));
     }
 }
Ejemplo n.º 4
0
 public RulePropertyRef_text(StructDecl ctx, string label)
     : base(ctx, label)
 {
 }
Ejemplo n.º 5
0
 public LabelRef(StructDecl ctx, string name)
     : base(ctx)
 {
     this.name = name;
 }
Ejemplo n.º 6
0
 public ActionText(StructDecl ctx, string text)
     : base(ctx)
 {
     this.text = text;
 }
Ejemplo n.º 7
0
 public Action(OutputModelFactory factory, StructDecl ctx, Template actionST)
     : base(factory, null)
 {
     chunks = new List<ActionChunk>();
     chunks.Add(new ActionTemplate(ctx, actionST));
 }
Ejemplo 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];
        }
Ejemplo n.º 9
0
 public QRetValueRef(StructDecl ctx, string dict, string name)
     : base(ctx, name)
 {
     this.dict = dict;
 }
Ejemplo n.º 10
0
 public ArgRef(StructDecl ctx, string name)
     : base(ctx, name)
 {
 }
Ejemplo n.º 11
0
 public ListLabelRef(StructDecl ctx, string name)
     : base(ctx, name)
 {
 }
Ejemplo n.º 12
0
 public TokenRef(StructDecl ctx, string name)
     : base(ctx)
 {
     this.name = name;
 }
Ejemplo n.º 13
0
 public SetAttr(StructDecl ctx, string name, IList<ActionChunk> rhsChunks)
     : base(ctx)
 {
     this.name = name;
     this.rhsChunks = rhsChunks;
 }
Ejemplo n.º 14
0
 public RetValueRef(StructDecl ctx, string name)
     : base(ctx)
 {
     this.name = name;
 }
Ejemplo n.º 15
0
 public TokenPropertyRef_int(StructDecl ctx, string label)
     : base(ctx, label)
 {
 }
Ejemplo n.º 16
0
 public TokenPropertyRef(StructDecl ctx, string label)
     : base(ctx)
 {
     this.label = label;
 }
Ejemplo n.º 17
0
 public ActionTemplate(StructDecl ctx, Template st)
     : base(ctx)
 {
     this.st = st;
 }
Ejemplo n.º 18
0
 public ThisRulePropertyRef_start(StructDecl ctx, string label)
     : base(ctx, label)
 {
 }
Ejemplo n.º 19
0
 public ActionChunk(StructDecl ctx)
 {
     this.ctx = ctx;
 }