Пример #1
0
        internal Parser(Tokenizer tokenizer, Analyzer analyzer)
        {
            this.patterns      = new List <ProductionPattern>();
            this.patternIds    = new Hashtable();
            this.tokens        = new ArrayList();
            this.errorLog      = new ParserLogException();
            this.errorRecovery = -1;
            this.Tokenizer     = tokenizer;
            var flag = analyzer == null;

            this.Analyzer = flag ? new Analyzer() : analyzer;
        }
Пример #2
0
        public Node Analyze(Node node)
        {
            var log = new ParserLogException();

            node = this.Analyze(node, log);
            var flag = log.Count > 0;

            if (flag)
            {
                throw log;
            }
            return(node);
        }
Пример #3
0
 public void Reset()
 {
     this.tokens.Clear();
     this.errorLog      = new ParserLogException();
     this.errorRecovery = -1;
 }
Пример #4
0
        private Node Analyze(Node node, ParserLogException log)
        {
            var  errorCount = log.Count;
            var  flag       = node is Production;
            Node analyze;

            if (flag)
            {
                var prod = (Production)node;
                prod = new Production(prod.Pattern);
                try
                {
                    this.Enter(prod);
                }
                catch (ParseException exception)
                {
                    ProjectData.SetProjectError(exception);
                    var e = exception;
                    log.AddError(e);
                    ProjectData.ClearProjectError();
                }
                var num = node.Count - 1;
                for (var i = 0; i <= num; i++)
                {
                    try
                    {
                        this.Child(prod, this.Analyze(node[i], log));
                    }
                    catch (ParseException expr_7A)
                    {
                        ProjectData.SetProjectError(expr_7A);
                        var e2 = expr_7A;
                        log.AddError(e2);
                        ProjectData.ClearProjectError();
                    }
                }
                try
                {
                    analyze = this.Exit(prod);
                    return(analyze);
                }
                catch (ParseException exception)
                {
                    ProjectData.SetProjectError(exception);
                    var e3    = exception;
                    var flag2 = errorCount == log.Count;
                    if (flag2)
                    {
                        log.AddError(e3);
                    }
                    ProjectData.ClearProjectError();
                }
            }
            else
            {
                node.ValuesArrayList.Clear();
                try
                {
                    this.Enter(node);
                }
                catch (ParseException exception)
                {
                    ProjectData.SetProjectError(exception);
                    var e4 = exception;
                    log.AddError(e4);
                    ProjectData.ClearProjectError();
                }
                try
                {
                    analyze = this.Exit(node);
                    return(analyze);
                }
                catch (ParseException exception)
                {
                    ProjectData.SetProjectError(exception);
                    var e5    = exception;
                    var flag3 = errorCount == log.Count;
                    if (flag3)
                    {
                        log.AddError(e5);
                    }
                    ProjectData.ClearProjectError();
                }
            }
            return(null);
        }