Exemplo n.º 1
0
        private void ThrowParseException(LookAheadSet set)
        {
            ArrayList list = new ArrayList();

            // Read tokens until mismatch
            while (set.IsNext(this, 1))
            {
                set = set.CreateNextSet(NextToken().Id);
            }

            // Find next token descriptions
            var initials = set.GetInitialTokens();

            for (int i = 0; i < initials.Length; i++)
            {
                list.Add(GetTokenDescription(initials[i]));
            }

            // Create exception
            var token = NextToken();

            throw new ParseException(ParseException.ErrorType.UNEXPECTED_TOKEN,
                                     token.ToShortString(),
                                     list,
                                     token.StartLine,
                                     token.StartColumn);
        }
Exemplo n.º 2
0
        private bool IsNext(ProductionPatternAlternative alt)
        {
            LookAheadSet set = alt.LookAhead;

            if (set == null)
            {
                return(false);
            }
            else
            {
                return(set.IsNext(this));
            }
        }
Exemplo n.º 3
0
        private bool IsNext(ProductionPattern pattern)
        {
            LookAheadSet set = pattern.LookAhead;

            if (set == null)
            {
                return(false);
            }
            else
            {
                return(set.IsNext(this));
            }
        }
Exemplo n.º 4
0
        private bool IsNext(ProductionPatternElement elem)
        {
            LookAheadSet set = elem.LookAhead;

            if (set != null)
            {
                return(set.IsNext(this));
            }
            else if (elem.IsToken())
            {
                return(elem.IsMatch(PeekToken(0)));
            }
            else
            {
                return(IsNext(GetPattern(elem.Id)));
            }
        }