コード例 #1
0
        private Token identifier()
        {
            int           startPosition = getCurrentPositionInInput();
            StringBuilder sbuf          = new StringBuilder();

            while ((isCSharpIdentifierStart(lookAhead(1))) ||
                   partOfConnector())
            {
                sbuf.Append(lookAhead(1));
                consume();
            }
            String readString = sbuf.ToString();

            // System.Console.WriteLine(readString);
            if (connectors.Contains(readString))
            {
                return(new Token((int)LogicTokenTypes.CONNECTOR, readString, startPosition));
            }
            else if (quantifiers.Contains(readString))
            {
                return(new Token((int)LogicTokenTypes.QUANTIFIER, readString, startPosition));
            }
            else if (domain.getPredicates().Contains(readString))
            {
                return(new Token((int)LogicTokenTypes.PREDICATE, readString, startPosition));
            }
            else if (domain.getFunctions().Contains(readString))
            {
                return(new Token((int)LogicTokenTypes.FUNCTION, readString, startPosition));
            }
            else if (domain.getConstants().Contains(readString))
            {
                return(new Token((int)LogicTokenTypes.CONSTANT, readString, startPosition));
            }
            else if (isVariable(readString))
            {
                return(new Token((int)LogicTokenTypes.VARIABLE, readString, startPosition));
            }
            else if (readString.Equals("="))
            {
                return(new Token((int)LogicTokenTypes.EQUALS, readString, startPosition));
            }
            else
            {
                throw new LexerException("Lexing error on character " + lookAhead(1) + " at position " + getCurrentPositionInInput(), getCurrentPositionInInput());
            }
        }