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)); }
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(); }
public PqlParser(PqlLexer lexer) { this.lexer = lexer; currentToken = lexer.GetNextToken(); isTestFile = false; statementCounter = 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); } }
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)); }
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)); }
private void Reset() { lexer.Reset(); currentToken = lexer.GetNextToken(); isTestFile = false; }