private static SubProduction GetSelectRule() { return(new SubProduction ( new List <ExpressionDefinition> { new TerminalExpressionDefinition { TokenType = TokenType.Select }, new NonTerminalExpressionDefinition { Identifier = ParserConstants.Top }, new NonTerminalExpressionDefinition { Identifier = ParserConstants.SelectColumns }, new TerminalExpressionDefinition { TokenType = TokenType.From }, new NonTerminalExpressionDefinition { Identifier = ParserConstants.Identifier }, new NonTerminalExpressionDefinition { Identifier = ParserConstants.Join }, new NonTerminalExpressionDefinition { Identifier = ParserConstants.Where }, new SemanticActionDefinition((ParsingNode node) => { IdentifierASTNode identifier = node.GetAttributeForKey <IdentifierASTNode>(ParserConstants.Identifier, ParserConstants.SyntaxTreeNode); BooleanExpressionASTNode condition = node.GetAttributeForKey <BooleanExpressionASTNode>(ParserConstants.Where, ParserConstants.SyntaxTreeNode); JoinASTNode join = node.GetAttributeForKey <JoinASTNode>(ParserConstants.Join, ParserConstants.SyntaxTreeNode); TopASTNode top = node.GetAttributeForKey <TopASTNode>(ParserConstants.Top, ParserConstants.SyntaxTreeNode); FromASTNode from = new FromASTNode() { Identifier = identifier }; node.Attributes.Add(ParserConstants.SyntaxTreeNode, new SelectASTNode() { From = from, Condition = condition, Join = join, Top = top, SelectColumns = node.GetAttributeForKey <List <FactorASTNode> >(ParserConstants.SelectColumns, ParserConstants.SyntaxTreeNodes) }); }) } )); }
private static SubProduction GetTopRule() { return(new SubProduction ( new List <ExpressionDefinition> { new TerminalExpressionDefinition { TokenType = TokenType.Top }, new TerminalExpressionDefinition { Key = "Integer", TokenType = TokenType.Integer }, new SemanticActionDefinition((ParsingNode node) => { TopASTNode astNode = new TopASTNode(); astNode.Amount = Convert.ToInt32(node.GetAttributeForKey <WordToken>("Integer", ParserConstants.Token).Lexeme); node.Attributes.Add(ParserConstants.SyntaxTreeNode, astNode); }) } )); }