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