private void ProcessSelect() { ReadNextToken(); SelectExpression selectExpression = new SelectExpression(); var parser = new SelectStatementParser(Tokenizer); _statement.SourceStatement = parser.Execute(); }
private Expression GetSelectExpression() { ReadNextToken(); SelectExpression selectExpression = new SelectExpression(); var parser = new SelectStatementParser(Tokenizer); selectExpression.Statement = parser.Execute(); return(selectExpression); }
public override CreateViewStatement Execute() { _statement = new CreateViewStatement(); _statement.Name = GetIdentifier(); ExpectTokens(Constants.As, Constants.Select); SelectStatementParser parser = new SelectStatementParser(Tokenizer); _statement.SelectBlock = parser.Execute(); return(_statement); }
private void ProcessJoins(Table table) { if (!Tokenizer.HasMoreTokens) { return; } do { JoinType?joinType = GetJoinType(); if (joinType == null) { return; } ExpectToken(Constants.Join); Join join; Table joinTable = null; if (Tokenizer.IsNextToken(Constants.OpenBracket)) { using (Tokenizer.ExpectBrackets()) { join = new DerivedJoin { Type = joinType.Value }; Tokenizer.ExpectToken(Constants.Select); var parser = new SelectStatementParser(Tokenizer); ((DerivedJoin)join).SelectStatement = parser.Execute(); } } else { join = new Join { Type = joinType.Value }; join.Name = GetTableName(); joinTable = new Table { Name = join.Name }; _statement.Tables.Add(joinTable); } Debug.Assert(join != null); Alias alias = new Alias(null); if (Tokenizer.IsNextToken(Constants.As)) { alias.Type = AliasType.As; Tokenizer.ReadNextToken(); } if (alias.Type != AliasType.Implicit || !Tokenizer.IsNextToken(Constants.On)) { alias.Name = GetIdentifier(); join.Alias = alias; if (joinTable != null) { joinTable.Alias = alias; } } ExpectToken(Constants.On); Expression expr = ProcessExpression(); if (!(expr is CriteriaExpression) && !(expr is NestedExpression && (expr as NestedExpression).Expression is CriteriaExpression)) { throw new SyntaxException("Expected Criteria Expression"); } join.Condition = expr; table.Joins.Add(join); } while (Tokenizer.HasMoreTokens && !Tokenizer.IsNextToken(Constants.Order, Constants.Group)); }