/// <summary> /// Gets the token. /// </summary> /// <param name="matchedDefinition">The definition of token type that fits requirements.</param> /// <param name="match">The match.</param> /// <returns>The token.</returns> protected override Token GetToken(TokenDefinition matchedDefinition, TokenMatch match) { var tokenText = match.SubMatch != null ? match.SubMatch.Value : match.Match.Value; var token = GetTokenCandidate(tokenText, matchedDefinition); Match definitionMatch = null; switch (token) { case TokenType.Desc: return(new DescToken(new TextSpan(Position, tokenText.Length))); case TokenType.Asc: return(new AscToken(new TextSpan(Position, tokenText.Length))); case TokenType.And: return(new AndToken(new TextSpan(Position, tokenText.Length))); case TokenType.Comma: return(new CommaToken(new TextSpan(Position, tokenText.Length))); case TokenType.Diff: return(new DiffToken(new TextSpan(Position, tokenText.Length))); case TokenType.Equality: return(new EqualityToken(new TextSpan(Position, tokenText.Length))); case TokenType.FSlash: return(new FSlashToken(new TextSpan(Position, tokenText.Length))); case TokenType.Function: return(new FunctionToken(tokenText, new TextSpan(Position, tokenText.Length))); case TokenType.Greater: return(new GreaterToken(new TextSpan(Position, tokenText.Length))); case TokenType.GreaterEqual: return(new GreaterEqualToken(new TextSpan(Position, tokenText.Length))); case TokenType.Hyphen: return(new HyphenToken(new TextSpan(Position, tokenText.Length))); case TokenType.LeftParenthesis: return(new LeftParenthesisToken(new TextSpan(Position, tokenText.Length))); case TokenType.Less: return(new LessToken(new TextSpan(Position, tokenText.Length))); case TokenType.LessEqual: return(new LessEqualToken(new TextSpan(Position, tokenText.Length))); case TokenType.Mod: return(new ModuloToken(new TextSpan(Position, tokenText.Length))); case TokenType.Not: return(new NotToken(new TextSpan(Position, tokenText.Length))); case TokenType.Decimal: return(new DecimalToken(tokenText.TrimEnd('d'), new TextSpan(Position, tokenText.Length))); case TokenType.Integer: return(new IntegerToken(tokenText, new TextSpan(Position, tokenText.Length))); case TokenType.Or: return(new OrToken(new TextSpan(Position, tokenText.Length))); case TokenType.Plus: return(new PlusToken(new TextSpan(Position, tokenText.Length))); case TokenType.RightParenthesis: return(new RightParenthesisToken(new TextSpan(Position, tokenText.Length))); case TokenType.Star: return(new StarToken(new TextSpan(Position, tokenText.Length))); case TokenType.Where: return(new WhereToken(new TextSpan(Position, tokenText.Length))); case TokenType.WhiteSpace: return(new WhiteSpaceToken(new TextSpan(Position, tokenText.Length))); case TokenType.From: return(new FromToken(new TextSpan(Position, tokenText.Length))); case TokenType.Select: return(new SelectToken(new TextSpan(Position, tokenText.Length))); case TokenType.Identifier: return(new ColumnToken(tokenText, new TextSpan(Position, tokenText.Length))); case TokenType.Variable: return(new VariableToken(tokenText, new TextSpan(Position, tokenText.Length))); case TokenType.Property: return(new AccessPropertyToken(tokenText, new TextSpan(Position, tokenText.Length))); case TokenType.Like: return(new LikeToken(new TextSpan(Position, tokenText.Length))); case TokenType.NotLike: return(new NotLikeToken(new TextSpan(Position, tokenText.Length))); case TokenType.RLike: return(new RLikeToken(new TextSpan(Position, tokenText.Length))); case TokenType.NotRLike: return(new NotRLikeToken(new TextSpan(Position, tokenText.Length))); case TokenType.As: return(new AsToken(new TextSpan(Position, tokenText.Length))); case TokenType.Except: return(new ExceptToken(new TextSpan(Position, tokenText.Length))); case TokenType.Union: return(new UnionToken(new TextSpan(Position, tokenText.Length))); case TokenType.Intersect: return(new IntersectToken(new TextSpan(Position, tokenText.Length))); case TokenType.UnionAll: return(new UnionAllToken(new TextSpan(Position, tokenText.Length))); case TokenType.Dot: return(new DotToken(new TextSpan(Position, tokenText.Length))); case TokenType.GroupBy: return(new GroupByToken(new TextSpan(Position, tokenText.Length))); case TokenType.Having: return(new HavingToken(new TextSpan(Position, tokenText.Length))); case TokenType.NumericAccess: definitionMatch = matchedDefinition.Regex.Match(tokenText); return(new NumericAccessToken(definitionMatch.Groups[1].Value, definitionMatch.Groups[2].Value, new TextSpan(Position, tokenText.Length))); case TokenType.KeyAccess: definitionMatch = matchedDefinition.Regex.Match(tokenText); return(new KeyAccessToken(definitionMatch.Groups[1].Value, definitionMatch.Groups[2].Value, new TextSpan(Position, tokenText.Length))); case TokenType.Contains: return(new ContainsToken(new TextSpan(Position, tokenText.Length))); case TokenType.Skip: return(new SkipToken(new TextSpan(Position, tokenText.Length))); case TokenType.Take: return(new TakeToken(new TextSpan(Position, tokenText.Length))); case TokenType.With: return(new WithToken(new TextSpan(Position, tokenText.Length))); case TokenType.On: return(new OnToken(new TextSpan(Position, tokenText.Length))); case TokenType.InnerJoin: return(new InnerJoinToken(new TextSpan(Position, tokenText.Length))); case TokenType.OuterJoin: var type = match.Match.Groups[1].Value.ToLowerInvariant() == "left" ? OuterJoinNode.OuterJoinType.Left : OuterJoinNode.OuterJoinType.Right; return(new OuterJoinToken(type, new TextSpan(Position, tokenText.Length))); //case TokenType.Function: // return new MethodAccessToken(match.Match.Groups[0].Value, // new TextSpan(Position, match.Match.Groups[0].Value.Length)); case TokenType.Is: return(new IsToken(new TextSpan(Position, tokenText.Length))); case TokenType.Null: return(new NullToken(new TextSpan(Position, tokenText.Length))); case TokenType.OrderBy: return(new OrderByToken(new TextSpan(Position, tokenText.Length))); case TokenType.True: return(new TrueToken(new TextSpan(Position, tokenText.Length))); case TokenType.False: return(new FalseToken(new TextSpan(Position, tokenText.Length))); case TokenType.In: return(new InToken(new TextSpan(Position, tokenText.Length))); case TokenType.NotIn: return(new NotInToken(new TextSpan(Position, tokenText.Length))); case TokenType.Table: return(new TableToken(new TextSpan(Position, tokenText.Length))); case TokenType.LBracket: return(new LBracketToken(new TextSpan(Position, tokenText.Length))); case TokenType.RBracket: return(new RBracketToken(new TextSpan(Position, tokenText.Length))); case TokenType.Semicolon: return(new SemicolonToken(new TextSpan(Position, tokenText.Length))); case TokenType.Case: return(new CaseToken(new TextSpan(Position, tokenText.Length))); case TokenType.When: return(new WhenToken(new TextSpan(Position, tokenText.Length))); case TokenType.Then: return(new ThenToken(new TextSpan(Position, tokenText.Length))); case TokenType.Else: return(new ElseToken(new TextSpan(Position, tokenText.Length))); case TokenType.End: return(new EndToken(new TextSpan(Position, tokenText.Length))); case TokenType.Declare: return(new DeclareToken(new TextSpan(Position, tokenText.Length))); case TokenType.Set: return(new SetToken(new TextSpan(Position, tokenText.Length))); case TokenType.Execute: return(new ExecuteToken(new TextSpan(Position, tokenText.Length))); } if (matchedDefinition.Regex.ToString() == TokenRegexDefinition.KWordBracketed) { return(new WordToken(match.Match.Groups[1].Value, new TextSpan(Position + 1, match.Match.Groups[1].Value.Length))); } return(new WordToken(tokenText, new TextSpan(Position, tokenText.Length))); }
public TokenGroupOr(TokenMatch left, TokenMatch right) { this.Left = left; this.Right = right; this.IsGroup = true; }
public Value(Type type, TokenMatch match) { m_value = match.value(); m_info = match.info(); m_type = type; }
public UndefinedReferenceException(TokenMatch dToken, ExpressionToken?expected) : base($"After this expression: '{dToken.Match.Value}' expected {expected}") { }
public TokenGroupOr(TokenMatch left, TokenMatch right) { Left = left; Right = right; IsGroup = true; }
public Identifier(TokenMatch match) { m_value = match.value(); m_info = match.info(); }
public UnexpectedTokenException(TokenMatch dToken) : base($"After this expression: '{dToken.Match.Value}'") { }