Esempio n. 1
0
 public ParsingState(ParsingGrammar grammar, ParsingRule rule, string text)
 {
     this.Grammar      = grammar;
     this.Text         = text;
     this.Position     = 0;
     this.Prev         = null;
     this.CurrentNodes = new ReadOnlyCollection <StringTreeNode>(new StringTreeNode[0]);
     this.CurrentRule  = rule;
     this.Log          = new IndentedWriter(" ");
     this.Parent       = new ParsingState(this, null, null, false);
     this.Skipping     = false;
 }
Esempio n. 2
0
        public ParsingState(ParsingState prev, ParsingState parent, ParsingRule parsingRule, bool skipping)
        {
            this.Grammar  = prev.Grammar;
            this.Text     = prev.Text;
            this.Log      = prev.Log;
            this.Position = prev.Position;

            this.Skipping     = skipping;
            this.Prev         = prev;
            this.CurrentNodes = new ReadOnlyCollection <StringTreeNode>(new StringTreeNode[0]);
            this.CurrentRule  = parsingRule;
            this.Parent       = parent;
        }
Esempio n. 3
0
        private ParsingState(ParsingState prev, ParsingRule rule, ParsingState parent, int pos, bool skipping, IEnumerable <StringTreeNode> nodes)
        {
            this.Grammar = prev.Grammar;
            this.Text    = prev.Text;
            this.Log     = prev.Log;

            this.Position     = pos;
            this.Skipping     = skipping;
            this.Prev         = prev;
            this.CurrentRule  = rule;
            this.CurrentNodes = new ReadOnlyCollection <StringTreeNode>(nodes.ToArray());
            this.Parent       = parent;
        }
Esempio n. 4
0
        public ParsingState EnterRule(ParsingRule parsingRule, bool skipping)
        {
            if (this.Depth > 100)
            {
                throw new ApplicationException("Recursion guard");
            }

            // Console.WriteLine("enter in " + parsingRule.Name + " @" + this.Position);
            return(new ParsingState(this, this, parsingRule, skipping)
            {
                Depth = this.Depth + 1
            });
        }