protected void loadNextTokenFromInput()
        {
            bool eoiEncountered = false;

            for (int i = 0; i < LookAhead - 1; i++)
            {
                lookAheadBuffer[i] = lookAheadBuffer[i + 1];
                if (isEndOfInput(lookAheadBuffer[i]))
                {
                    eoiEncountered = true;
                    break;
                }
            }
            if (!eoiEncountered)
            {
                try
                {
                    lookAheadBuffer[LookAhead - 1] = lexer.nextToken();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
        }
Пример #2
0
 public void testLexBasicExpression()
 {
     lexer.setInput("( P )");
     Assert.AreEqual(new Token(LogicTokenTypes.LPAREN, "(", 0),
                     lexer.nextToken());
     Assert.AreEqual(new Token(LogicTokenTypes.CONSTANT, "P", 2),
                     lexer.nextToken());
     Assert.AreEqual(new Token(LogicTokenTypes.RPAREN, ")", 4),
                     lexer.nextToken());
     Assert.AreEqual(new Token(LogicTokenTypes.EOI, "EOI", 5),
                     lexer.nextToken());
 }