Example #1
0
 internal void AddError(ParseException e, bool recovery)
 {
     if (_errorRecovery <= 0)
     {
         _errorLog.AddError(e);
     }
     if (recovery)
     {
         _errorRecovery = 3;
     }
 }
Example #2
0
        private Node Analyze(Node node, ParserLogException log)
        {
            var errorCount = log.Count;

            if (node is Production)
            {
                var prod = (Production)node;
                prod = NewProduction(prod.Pattern);
                try
                {
                    Enter(prod);
                }
                catch (ParseException e)
                {
                    log.AddError(e);
                }
                for (int i = 0; i < node.Count; i++)
                {
                    try
                    {
                        Child(prod, Analyze(node[i], log));
                    }
                    catch (ParseException e)
                    {
                        log.AddError(e);
                    }
                }
                try
                {
                    return(Exit(prod));
                }
                catch (ParseException e)
                {
                    if (errorCount == log.Count)
                    {
                        log.AddError(e);
                    }
                }
            }
            else
            {
                node.Values.Clear();
                try
                {
                    Enter(node);
                }
                catch (ParseException e)
                {
                    log.AddError(e);
                }
                try
                {
                    return(Exit(node));
                }
                catch (ParseException e)
                {
                    if (errorCount == log.Count)
                    {
                        log.AddError(e);
                    }
                }
            }
            return(null);
        }