private Expression ParseExpression() { Expression value; if (_tokenStream.IsEmpty()) { value = new NullExpression(); } else { Token tok = PeekToken(); if (tok == ReferenceStartToken || tok == OldReferenceStartToken) { value = ParseReference(); } else if (tok.type == TokenType.Number || (IsIdentifier(tok) && !IsKeyword(tok))) { value = ParsePrimitive(); } else if (IsQuotedString(tok)) { value = ParseString(); } else if (tok == LSquareToken) { value = ParseCollection(); } else if (tok == LBraceToken) { value = ParseObject(); } else if (tok == LParenToken) { value = ParseCast(); } else if (tok == NewToken) { value = ParseConstructedObject(); } else { throw new ParseException(string.Format("Unexpected token: {0} at Line: {1}, Position: {2}", tok, tok.linenumber, tok.position)); } } return(value); }
public bool IsEmpty() { return(tokens.Count == 0 && sourceStream.IsEmpty()); }