コード例 #1
0
        private PqlPatternNode Pattern()
        {
            PqlToken   id      = currentToken;
            PqlSynonym synonym = new PqlSynonym(id);

            Eat(PqlTokenType.IDENT);
            Eat(PqlTokenType.LPAREN);
            PqlArgument varRef = Ref();

            Eat(PqlTokenType.COMMA);

            PqlExpr expr = null;

            if (currentToken.Type == PqlTokenType.STRING)
            {
                expr = Expr(true);
            }
            else if (currentToken.Type == PqlTokenType.FLOOR)
            {
                Eat(PqlTokenType.FLOOR);
                if (currentToken.Type == PqlTokenType.STRING)
                {
                    expr = Expr(false);
                    Eat(PqlTokenType.FLOOR);
                }
                else if (currentToken.Type == PqlTokenType.COMMA)
                {
                    Eat(PqlTokenType.COMMA);
                    Eat(PqlTokenType.FLOOR);
                }
            }
            Eat(PqlTokenType.RPAREN);
            return(new PqlPatternNode(synonym, varRef, expr));
        }
コード例 #2
0
        private PqlArgument Ref()
        {
            PqlToken id = currentToken;

            if (currentToken.Type == PqlTokenType.IDENT)
            {
                Eat(PqlTokenType.IDENT);
                if (currentToken.Type == PqlTokenType.DOT)
                {
                    Eat(PqlTokenType.DOT);
                    PqlToken attrRef = currentToken;
                    Eat(PqlTokenType.ATTRIBUTE);
                    return(new PqlAttrRef(id, attrRef));
                }
                return(new PqlSynonym(id));
            }
            else if (currentToken.Type == PqlTokenType.INTEGER)
            {
                Eat(PqlTokenType.INTEGER);
                return(new PqlInteger(id));
            }
            else if (currentToken.Type == PqlTokenType.STRING)
            {
                id = currentToken;
                Eat(PqlTokenType.STRING);
                return(new PqlString(id));
            }
            else if (currentToken.Type == PqlTokenType.FLOOR)
            {
                Eat(PqlTokenType.FLOOR);
                return(new PqlEmptyArg());
            }
            throw new Exception();
        }
コード例 #3
0
 public PqlParser(PqlLexer lexer)
 {
     this.lexer       = lexer;
     currentToken     = lexer.GetNextToken();
     isTestFile       = false;
     statementCounter = 0;
 }
コード例 #4
0
 private void Eat(PqlTokenType type)
 {
     if (currentToken.Type == type)
     {
         currentToken = lexer.GetNextToken();
     }
     else
     {
         //throw new PqlParserException("Niespodziewany token. Spodziewany: " + type.ToString() + " Rzeczywisty: " + currentToken.Type.ToString(), lexer.lineCounter, lexer.rowCounter);
     }
 }
コード例 #5
0
        private PqlDeclaration Declaration(PqlToken declarationType)
        {
            PqlToken   id      = currentToken;
            PqlSynonym synonym = new PqlSynonym(id);

            Eat(PqlTokenType.IDENT);
            if (currentToken.Type == PqlTokenType.COMMA)
            {
                Eat(PqlTokenType.COMMA);
            }
            return(new PqlDeclaration(declarationType, synonym));
        }
コード例 #6
0
        private PqlElem Elem()
        {
            PqlToken id = currentToken;

            Eat(PqlTokenType.IDENT);
            if (currentToken.Type == PqlTokenType.DOT)
            {
                Eat(PqlTokenType.DOT);
                PqlToken attrRef = currentToken;
                Eat(PqlTokenType.ATTRIBUTE);
                return(new PqlAttrRef(id, attrRef));
            }
            return(new PqlSynonym(id));
        }
コード例 #7
0
 private void Reset()
 {
     lexer.Reset();
     currentToken = lexer.GetNextToken();
     isTestFile   = false;
 }