AIMA.Core.Logic.Propositional.Parsing.PELexer.nextToken C# (CSharp) Метод

nextToken() публичный Метод

public nextToken ( ) : Token
Результат AIMA.Core.Logic.Common.Token
        public override Token nextToken()
        {
            if (lookAhead(1) == '(')
            {
                consume();
                return new Token((int)LogicTokenTypes.LPAREN, "(");

            }
            else if (lookAhead(1) == ')')
            {
                consume();
                return new Token((int)LogicTokenTypes.RPAREN, ")");
            }
            else if (identifierDetected())
            {
                return symbol();

            }
            else if (char.IsWhiteSpace(lookAhead(1)))
            {
                consume();
                return nextToken();
                // return whiteSpace();
            }
            else if ((int)lookAhead(1) == 65535)
            {
                return new Token((int)LogicTokenTypes.EOI, "EOI");
            }
            else
            {
                throw new ApplicationException("Lexing error on character "
                        + lookAhead(1));
            }

        }

Usage Example

Пример #1
0
 public void testLexImpliesExpression()
 {
     PELexer pelexer = new PELexer();
     pelexer.setInput("(P => Q)");
     Assert.AreEqual(new Token((int)LogicTokenTypes.LPAREN, "("), pelexer
             .nextToken());
     Assert.AreEqual(new Token((int)LogicTokenTypes.SYMBOL, "P"), pelexer
             .nextToken());
     Assert.AreEqual(new Token((int)LogicTokenTypes.CONNECTOR, "=>"), pelexer
             .nextToken());
 }
All Usage Examples Of AIMA.Core.Logic.Propositional.Parsing.PELexer::nextToken