/// <summary> /// As we flatten the tree, we use UP, DOWN nodes to represent /// the tree structure. When debugging we need unique nodes /// so instantiate new ones when uniqueNavigationNodes is true. /// </summary> protected internal virtual void AddNavigationNode(int ttype) { object navNode = null; if (ttype == Token.DOWN) { if (HasUniqueNavigationNodes) { navNode = adaptor.Create(Token.DOWN, "DOWN"); } else { navNode = down; } } else { if (HasUniqueNavigationNodes) { navNode = adaptor.Create(Token.UP, "UP"); } else { navNode = up; } } AddLookahead(navNode); }
/** As we flatten the tree, we use UP, DOWN nodes to represent * the tree structure. When debugging we need unique nodes * so instantiate new ones when uniqueNavigationNodes is true. */ protected virtual void AddNavigationNode(int ttype) { object navNode = null; if (ttype == TokenTypes.Down) { if (UniqueNavigationNodes) { navNode = adaptor.Create(TokenTypes.Down, "DOWN"); } else { navNode = down; } } else { if (UniqueNavigationNodes) { navNode = adaptor.Create(TokenTypes.Up, "UP"); } else { navNode = up; } } nodes.Add(navNode); }
public UnBufferedTreeNodeStream(ITreeAdaptor adaptor, object tree) { this.root = tree; this.adaptor = adaptor; Reset(); down = adaptor.Create(Token.DOWN, "DOWN"); up = adaptor.Create(Token.UP, "UP"); eof = adaptor.Create(Token.EOF, "EOF"); }
public BufferedTreeNodeStream(ITreeAdaptor adaptor, object tree, int initialBufferSize) { this.root = tree; this.adaptor = adaptor; nodes = new List <object>(initialBufferSize); down = adaptor.Create(TokenTypes.Down, "DOWN"); up = adaptor.Create(TokenTypes.Up, "UP"); eof = adaptor.Create(TokenTypes.EndOfFile, "EOF"); }
public CommonTreeNodeStream(ITreeAdaptor adaptor, object tree, int initialBufferSize) { this.root = tree; this.adaptor = adaptor; nodes = new ArrayList(initialBufferSize); down = adaptor.Create(Token.DOWN, "DOWN"); up = adaptor.Create(Token.UP, "UP"); eof = adaptor.Create(Token.EOF, "EOF"); }
public BufferedTreeNodeStream(ITreeAdaptor adaptor, object tree, int initialBufferSize) { this.root = tree; this.adaptor = adaptor; nodes = new List <object>(initialBufferSize); down = adaptor.Create(TokenConstants.DOWN, "DOWN"); up = adaptor.Create(TokenConstants.UP, "UP"); eof = adaptor.Create(TokenConstants.EOF, "EOF"); }
public TreeIterator(ITreeAdaptor adaptor, object tree) { this.adaptor = adaptor; this.tree = tree; this.root = tree; nodes = new Queue <object>(); down = adaptor.Create(TokenConstants.DOWN, "DOWN"); up = adaptor.Create(TokenConstants.UP, "UP"); eof = adaptor.Create(TokenConstants.EOF, "EOF"); }
public TreeIterator(ITreeAdaptor adaptor, object tree) { this.adaptor = adaptor; this.tree = tree; this.root = tree; this.nodes = new Queue <object>(); this.down = adaptor.Create(2, "DOWN"); this.up = adaptor.Create(3, "UP"); this.eof = adaptor.Create(-1, "EOF"); }
public TreeIterator(ITreeAdaptor adaptor, object tree) { this.adaptor = adaptor; this.tree = tree; this.root = tree; nodes = new Queue <object>(); down = adaptor.Create(TokenTypes.Down, "DOWN"); up = adaptor.Create(TokenTypes.Up, "UP"); eof = adaptor.Create(TokenTypes.EndOfFile, "EOF"); }
// $ANTLR start "id" // ..\\Plugin.EffiProz\\AntlrParser\\EffiProz.g:14:1: id : ( T_IDENT | T_QUOTED_IDENT ); public EffiProzParser.id_return id() // throws RecognitionException [1] { EffiProzParser.id_return retval = new EffiProzParser.id_return(); retval.Start = input.LT(1); object root_0 = null; IToken set1 = null; object set1_tree = null; try { // ..\\Plugin.EffiProz\\AntlrParser\\EffiProz.g:14:3: ( T_IDENT | T_QUOTED_IDENT ) // ..\\Plugin.EffiProz\\AntlrParser\\EffiProz.g: { root_0 = (object)adaptor.GetNilNode(); set1 = (IToken)input.LT(1); if ((input.LA(1) >= T_IDENT && input.LA(1) <= T_QUOTED_IDENT)) { input.Consume(); adaptor.AddChild(root_0, (object)adaptor.Create(set1)); state.errorRecovery = false; } else { MismatchedSetException mse = new MismatchedSetException(null, input); throw mse; } } retval.Stop = input.LT(-1); retval.Tree = (object)adaptor.RulePostProcessing(root_0); adaptor.SetTokenBoundaries(retval.Tree, (IToken)retval.Start, (IToken)retval.Stop); } catch (RecognitionException re) { ReportError(re); Recover(input, re); // Conversion of the second argument necessary, but harmless retval.Tree = (object)adaptor.ErrorNode(input, (IToken)retval.Start, input.LT(-1), re); } finally { } return(retval); }
public CommonTreeNodeStream(ITreeAdaptor adaptor, object tree) : base(adaptor.Create(TokenConstants.EOF, "EOF")) // set EOF { this._root = tree; this._adaptor = adaptor; _it = new TreeIterator(adaptor, _root); _it.eof = this.Eof; // make sure tree iterator returns the EOF we want }
public IASTNode CreateNode(int type, string text, params IASTNode[] children) { var parent = (IASTNode)_adaptor.Create(type, text); parent.AddChildren(children); return(parent); }
protected override object GetMissingSymbol(IIntStream input, RecognitionException e, int expectedTokenType, BitSet follow) { string tokenText = "<missing " + TokenNames[expectedTokenType] + ">"; ITreeAdaptor adaptor = ((ITreeNodeStream)e.Input).TreeAdaptor; return(adaptor.Create(new CommonToken(expectedTokenType, tokenText))); }
protected Object adaptorCreate(ITreeAdaptor ta, int token, String text, IToken baset) { return(ta.Create(token, baset, text)); }
public virtual object ParseNode() { // "%label:" prefix string label = null; if (ttype == TreePatternLexer.Percent) { ttype = tokenizer.NextToken(); if (ttype != TreePatternLexer.Id) { return(null); } label = tokenizer.sval.ToString(); ttype = tokenizer.NextToken(); if (ttype != TreePatternLexer.Colon) { return(null); } ttype = tokenizer.NextToken(); // move to ID following colon } // Wildcard? if (ttype == TreePatternLexer.Dot) { ttype = tokenizer.NextToken(); IToken wildcardPayload = new CommonToken(0, "."); TreeWizard.TreePattern node = new TreeWizard.WildcardTreePattern(wildcardPayload); if (label != null) { node.label = label; } return(node); } // "ID" or "ID[arg]" if (ttype != TreePatternLexer.Id) { return(null); } string tokenName = tokenizer.sval.ToString(); ttype = tokenizer.NextToken(); if (tokenName.Equals("nil")) { return(adaptor.Nil()); } string text = tokenName; // check for arg string arg = null; if (ttype == TreePatternLexer.Arg) { arg = tokenizer.sval.ToString(); text = arg; ttype = tokenizer.NextToken(); } // create node int treeNodeType = wizard.GetTokenType(tokenName); if (treeNodeType == TokenTypes.Invalid) { return(null); } object node2; node2 = adaptor.Create(treeNodeType, text); if (label != null && node2.GetType() == typeof(TreeWizard.TreePattern)) { ((TreeWizard.TreePattern)node2).label = label; } if (arg != null && node2.GetType() == typeof(TreeWizard.TreePattern)) { ((TreeWizard.TreePattern)node2).hasTextArg = true; } return(node2); }
// $ANTLR start "find_dep_item" // ..\\Plugin.mssql\\AntlrParser\\MSSQL.g:16:1: find_dep_item[DepsCollector dc] : ( keyword | operator_no_dot | T_NSTRING | T_STRING | T_INTEGER | T_FLOAT | T_BINARYNUM | T_BLOB | name1= id ( DOT ( DOT )? (name2= id | ASTERISK ) )* ); public MSSQLParser.find_dep_item_return find_dep_item(DepsCollector dc) // throws RecognitionException [1] { MSSQLParser.find_dep_item_return retval = new MSSQLParser.find_dep_item_return(); retval.Start = input.LT(1); object root_0 = null; IToken T_NSTRING4 = null; IToken T_STRING5 = null; IToken T_INTEGER6 = null; IToken T_FLOAT7 = null; IToken T_BINARYNUM8 = null; IToken T_BLOB9 = null; IToken DOT10 = null; IToken DOT11 = null; IToken ASTERISK12 = null; MSSQLParser.id_return name1 = default(MSSQLParser.id_return); MSSQLParser.id_return name2 = default(MSSQLParser.id_return); MSSQLParser.keyword_return keyword2 = default(MSSQLParser.keyword_return); MSSQLParser.operator_no_dot_return operator_no_dot3 = default(MSSQLParser.operator_no_dot_return); object T_NSTRING4_tree = null; object T_STRING5_tree = null; object T_INTEGER6_tree = null; object T_FLOAT7_tree = null; object T_BINARYNUM8_tree = null; object T_BLOB9_tree = null; object DOT10_tree = null; object DOT11_tree = null; object ASTERISK12_tree = null; try { // ..\\Plugin.mssql\\AntlrParser\\MSSQL.g:17:5: ( keyword | operator_no_dot | T_NSTRING | T_STRING | T_INTEGER | T_FLOAT | T_BINARYNUM | T_BLOB | name1= id ( DOT ( DOT )? (name2= id | ASTERISK ) )* ) int alt5 = 9; switch (input.LA(1)) { case ADD: case ALTER: case AND: case AS: case ASC: case BEGIN: case BETWEEN: case BY: case CASCADE: case CASE: case CAST: case CHECK: case COLLATE: case COLUMN: case COMMIT: case CONFLICT: case CONSTRAINT: case CREATE: case CROSS: case CURRENT_TIME: case CURRENT_DATE: case CURRENT_TIMESTAMP: case UTC_TIMESTAMP: case DATABASE: case DEFAULT: case DELETE: case DESC: case DISTINCT: case DROP: case ELSE: case END: case ESCAPE: case EXCEPT: case EXCLUSIVE: case EXISTS: case EXPLAIN: case FOR: case FOREIGN: case FROM: case GROUP: case HAVING: case IF: case IN: case INDEX: case INNER: case INSERT: case INTERSECT: case INTO: case IS: case JOIN: case KEY: case LEFT: case LIKE: case NOT: case NULL: case OF: case ON: case OR: case ORDER: case OUTER: case PRIMARY: case REFERENCES: case ROLLBACK: case SELECT: case SET: case TABLE: case TEMPORARY: case TEMP: case THEN: case TO: case TRANSACTION: case TRIGGER: case UNION: case UNIQUE: case UPDATE: case VALUES: case VIEW: case WHEN: case WHERE: case WITH: case PARSER: case XOR: { alt5 = 1; } break; case ASTERISK: case EQUALS: case SAFEEQUALS: case EQUALS2: case NOT_EQUALS: case NOT_EQUALS2: case LESS: case LESS_OR_EQ: case GREATER: case GREATER_OR_EQ: case SHIFT_LEFT: case SHIFT_RIGHT: case AMPERSAND: case DOUBLE_AMPERSAND: case PIPE: case DOUBLE_PIPE: case PLUS: case MINUS: case TILDA: case SLASH: case PERCENT: case SEMI: case COMMA: case LPAREN: case RPAREN: case QUESTION: case EXCLAMATION: case COLON: case AT: case DOLLAR: case ARROW_UP: { alt5 = 2; } break; case T_NSTRING: { alt5 = 3; } break; case T_STRING: { alt5 = 4; } break; case T_INTEGER: { alt5 = 5; } break; case T_FLOAT: { alt5 = 6; } break; case T_BINARYNUM: { alt5 = 7; } break; case T_BLOB: { alt5 = 8; } break; case T_IDENT: case T_QUOTED_IDENT: { alt5 = 9; } break; default: NoViableAltException nvae_d5s0 = new NoViableAltException("", 5, 0, input); throw nvae_d5s0; } switch (alt5) { case 1: // ..\\Plugin.mssql\\AntlrParser\\MSSQL.g:17:7: keyword { root_0 = (object)adaptor.GetNilNode(); PushFollow(FOLLOW_keyword_in_find_dep_item52); keyword2 = keyword(); state.followingStackPointer--; adaptor.AddChild(root_0, keyword2.Tree); } break; case 2: // ..\\Plugin.mssql\\AntlrParser\\MSSQL.g:17:17: operator_no_dot { root_0 = (object)adaptor.GetNilNode(); PushFollow(FOLLOW_operator_no_dot_in_find_dep_item56); operator_no_dot3 = operator_no_dot(); state.followingStackPointer--; adaptor.AddChild(root_0, operator_no_dot3.Tree); } break; case 3: // ..\\Plugin.mssql\\AntlrParser\\MSSQL.g:17:35: T_NSTRING { root_0 = (object)adaptor.GetNilNode(); T_NSTRING4 = (IToken)Match(input, T_NSTRING, FOLLOW_T_NSTRING_in_find_dep_item60); T_NSTRING4_tree = (object)adaptor.Create(T_NSTRING4); adaptor.AddChild(root_0, T_NSTRING4_tree); } break; case 4: // ..\\Plugin.mssql\\AntlrParser\\MSSQL.g:17:47: T_STRING { root_0 = (object)adaptor.GetNilNode(); T_STRING5 = (IToken)Match(input, T_STRING, FOLLOW_T_STRING_in_find_dep_item64); T_STRING5_tree = (object)adaptor.Create(T_STRING5); adaptor.AddChild(root_0, T_STRING5_tree); } break; case 5: // ..\\Plugin.mssql\\AntlrParser\\MSSQL.g:17:58: T_INTEGER { root_0 = (object)adaptor.GetNilNode(); T_INTEGER6 = (IToken)Match(input, T_INTEGER, FOLLOW_T_INTEGER_in_find_dep_item68); T_INTEGER6_tree = (object)adaptor.Create(T_INTEGER6); adaptor.AddChild(root_0, T_INTEGER6_tree); } break; case 6: // ..\\Plugin.mssql\\AntlrParser\\MSSQL.g:17:70: T_FLOAT { root_0 = (object)adaptor.GetNilNode(); T_FLOAT7 = (IToken)Match(input, T_FLOAT, FOLLOW_T_FLOAT_in_find_dep_item72); T_FLOAT7_tree = (object)adaptor.Create(T_FLOAT7); adaptor.AddChild(root_0, T_FLOAT7_tree); } break; case 7: // ..\\Plugin.mssql\\AntlrParser\\MSSQL.g:17:80: T_BINARYNUM { root_0 = (object)adaptor.GetNilNode(); T_BINARYNUM8 = (IToken)Match(input, T_BINARYNUM, FOLLOW_T_BINARYNUM_in_find_dep_item76); T_BINARYNUM8_tree = (object)adaptor.Create(T_BINARYNUM8); adaptor.AddChild(root_0, T_BINARYNUM8_tree); } break; case 8: // ..\\Plugin.mssql\\AntlrParser\\MSSQL.g:17:94: T_BLOB { root_0 = (object)adaptor.GetNilNode(); T_BLOB9 = (IToken)Match(input, T_BLOB, FOLLOW_T_BLOB_in_find_dep_item80); T_BLOB9_tree = (object)adaptor.Create(T_BLOB9); adaptor.AddChild(root_0, T_BLOB9_tree); } break; case 9: // ..\\Plugin.mssql\\AntlrParser\\MSSQL.g:18:9: name1= id ( DOT ( DOT )? (name2= id | ASTERISK ) )* { root_0 = (object)adaptor.GetNilNode(); PushFollow(FOLLOW_id_in_find_dep_item94); name1 = id(); state.followingStackPointer--; adaptor.AddChild(root_0, name1.Tree); var name = new DepsName(); name.AddComponent(UnquoteName(((name1 != null) ? input.ToString((IToken)(name1.Start), (IToken)(name1.Stop)) : null))); // ..\\Plugin.mssql\\AntlrParser\\MSSQL.g:19:9: ( DOT ( DOT )? (name2= id | ASTERISK ) )* do { int alt4 = 2; int LA4_0 = input.LA(1); if ((LA4_0 == DOT)) { alt4 = 1; } switch (alt4) { case 1: // ..\\Plugin.mssql\\AntlrParser\\MSSQL.g:19:10: DOT ( DOT )? (name2= id | ASTERISK ) { DOT10 = (IToken)Match(input, DOT, FOLLOW_DOT_in_find_dep_item107); DOT10_tree = (object)adaptor.Create(DOT10); adaptor.AddChild(root_0, DOT10_tree); // ..\\Plugin.mssql\\AntlrParser\\MSSQL.g:19:14: ( DOT )? int alt2 = 2; int LA2_0 = input.LA(1); if ((LA2_0 == DOT)) { alt2 = 1; } switch (alt2) { case 1: // ..\\Plugin.mssql\\AntlrParser\\MSSQL.g:19:14: DOT { DOT11 = (IToken)Match(input, DOT, FOLLOW_DOT_in_find_dep_item109); DOT11_tree = (object)adaptor.Create(DOT11); adaptor.AddChild(root_0, DOT11_tree); } break; } // ..\\Plugin.mssql\\AntlrParser\\MSSQL.g:19:19: (name2= id | ASTERISK ) int alt3 = 2; int LA3_0 = input.LA(1); if (((LA3_0 >= T_IDENT && LA3_0 <= T_QUOTED_IDENT))) { alt3 = 1; } else if ((LA3_0 == ASTERISK)) { alt3 = 2; } else { NoViableAltException nvae_d3s0 = new NoViableAltException("", 3, 0, input); throw nvae_d3s0; } switch (alt3) { case 1: // ..\\Plugin.mssql\\AntlrParser\\MSSQL.g:19:20: name2= id { PushFollow(FOLLOW_id_in_find_dep_item115); name2 = id(); state.followingStackPointer--; adaptor.AddChild(root_0, name2.Tree); name.AddComponent(UnquoteName(((name2 != null) ? input.ToString((IToken)(name2.Start), (IToken)(name2.Stop)) : null))); } break; case 2: // ..\\Plugin.mssql\\AntlrParser\\MSSQL.g:19:79: ASTERISK { ASTERISK12 = (IToken)Match(input, ASTERISK, FOLLOW_ASTERISK_in_find_dep_item121); ASTERISK12_tree = (object)adaptor.Create(ASTERISK12); adaptor.AddChild(root_0, ASTERISK12_tree); } break; } } break; default: goto loop4; } } while (true); loop4: ; // Stops C# compiler whining that label 'loop4' has no statements dc.AddName(name); } break; } retval.Stop = input.LT(-1); retval.Tree = (object)adaptor.RulePostProcessing(root_0); adaptor.SetTokenBoundaries(retval.Tree, (IToken)retval.Start, (IToken)retval.Stop); } catch (RecognitionException re) { ReportError(re); Recover(input, re); // Conversion of the second argument necessary, but harmless retval.Tree = (object)adaptor.ErrorNode(input, (IToken)retval.Start, input.LT(-1), re); } finally { } return(retval); }
// $ANTLR start "additiveExpression" // D:\\Szkolenia\\Artykuł ProgramistaMag - DSL\\Code\\DSLSamples\\SimpleDSL\\Simple.g:10:0: additiveExpression : ( multiplicativeExpression ) ( ( '+' | '-' ) multiplicativeExpression )* ; public SimpleParser.additiveExpression_return additiveExpression() // throws RecognitionException [1] { SimpleParser.additiveExpression_return retval = new SimpleParser.additiveExpression_return(); retval.Start = input.LT(1); CommonTree root_0 = null; IToken char_literal3 = null; IToken char_literal4 = null; SimpleParser.multiplicativeExpression_return multiplicativeExpression2 = default(SimpleParser.multiplicativeExpression_return); SimpleParser.multiplicativeExpression_return multiplicativeExpression5 = default(SimpleParser.multiplicativeExpression_return); CommonTree char_literal3_tree = null; CommonTree char_literal4_tree = null; try { // D:\\Szkolenia\\Artykuł ProgramistaMag - DSL\\Code\\DSLSamples\\SimpleDSL\\Simple.g:11:2: ( ( multiplicativeExpression ) ( ( '+' | '-' ) multiplicativeExpression )* ) // D:\\Szkolenia\\Artykuł ProgramistaMag - DSL\\Code\\DSLSamples\\SimpleDSL\\Simple.g:11:2: ( multiplicativeExpression ) ( ( '+' | '-' ) multiplicativeExpression )* { root_0 = (CommonTree)adaptor.GetNilNode(); // D:\\Szkolenia\\Artykuł ProgramistaMag - DSL\\Code\\DSLSamples\\SimpleDSL\\Simple.g:11:2: ( multiplicativeExpression ) // D:\\Szkolenia\\Artykuł ProgramistaMag - DSL\\Code\\DSLSamples\\SimpleDSL\\Simple.g:11:3: multiplicativeExpression { PushFollow(FOLLOW_multiplicativeExpression_in_additiveExpression52); multiplicativeExpression2 = multiplicativeExpression(); state.followingStackPointer--; adaptor.AddChild(root_0, multiplicativeExpression2.Tree); } // D:\\Szkolenia\\Artykuł ProgramistaMag - DSL\\Code\\DSLSamples\\SimpleDSL\\Simple.g:11:29: ( ( '+' | '-' ) multiplicativeExpression )* do { int alt2 = 2; int LA2_0 = input.LA(1); if ((LA2_0 == 7 || LA2_0 == 13)) { alt2 = 1; } switch (alt2) { case 1: // D:\\Szkolenia\\Artykuł ProgramistaMag - DSL\\Code\\DSLSamples\\SimpleDSL\\Simple.g:11:30: ( '+' | '-' ) multiplicativeExpression { // D:\\Szkolenia\\Artykuł ProgramistaMag - DSL\\Code\\DSLSamples\\SimpleDSL\\Simple.g:11:30: ( '+' | '-' ) int alt1 = 2; int LA1_0 = input.LA(1); if ((LA1_0 == 13)) { alt1 = 1; } else if ((LA1_0 == 7)) { alt1 = 2; } else { NoViableAltException nvae_d1s0 = new NoViableAltException("", 1, 0, input); throw nvae_d1s0; } switch (alt1) { case 1: // D:\\Szkolenia\\Artykuł ProgramistaMag - DSL\\Code\\DSLSamples\\SimpleDSL\\Simple.g:11:31: '+' { char_literal3 = (IToken)Match(input, 13, FOLLOW_13_in_additiveExpression57); char_literal3_tree = (CommonTree)adaptor.Create(char_literal3); root_0 = (CommonTree)adaptor.BecomeRoot(char_literal3_tree, root_0); } break; case 2: // D:\\Szkolenia\\Artykuł ProgramistaMag - DSL\\Code\\DSLSamples\\SimpleDSL\\Simple.g:11:36: '-' { char_literal4 = (IToken)Match(input, 7, FOLLOW_7_in_additiveExpression60); char_literal4_tree = (CommonTree)adaptor.Create(char_literal4); root_0 = (CommonTree)adaptor.BecomeRoot(char_literal4_tree, root_0); } break; } PushFollow(FOLLOW_multiplicativeExpression_in_additiveExpression64); multiplicativeExpression5 = multiplicativeExpression(); state.followingStackPointer--; adaptor.AddChild(root_0, multiplicativeExpression5.Tree); } break; default: goto loop2; } } while (true); loop2: ; // Stops C# compiler whining that label 'loop2' has no statements } retval.Stop = input.LT(-1); retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0); adaptor.SetTokenBoundaries(retval.Tree, (IToken)retval.Start, (IToken)retval.Stop); } catch (RecognitionException re) { ReportError(re); Recover(input, re); // Conversion of the second argument necessary, but harmless retval.Tree = (CommonTree)adaptor.ErrorNode(input, (IToken)retval.Start, input.LT(-1), re); } finally { } return(retval); }
// $ANTLR start "create_index" // ..\\Plugin.postgre\\AntlrParser\\PostgreSQL.g:14:1: create_index[IndexConstraint index] : CREATE ( UNIQUE )? INDEX ( CONCURRENTLY )? name= index_name ON table_name ( USING id )? LPAREN index_column[index] ( COMMA index_column[index] )* RPAREN ; public PostgreSQLParser.create_index_return create_index(IndexConstraint index) // throws RecognitionException [1] { PostgreSQLParser.create_index_return retval = new PostgreSQLParser.create_index_return(); retval.Start = input.LT(1); object root_0 = null; IToken CREATE1 = null; IToken UNIQUE2 = null; IToken INDEX3 = null; IToken CONCURRENTLY4 = null; IToken ON5 = null; IToken USING7 = null; IToken LPAREN9 = null; IToken COMMA11 = null; IToken RPAREN13 = null; PostgreSQLParser.index_name_return name = default(PostgreSQLParser.index_name_return); PostgreSQLParser.table_name_return table_name6 = default(PostgreSQLParser.table_name_return); PostgreSQLParser.id_return id8 = default(PostgreSQLParser.id_return); PostgreSQLParser.index_column_return index_column10 = default(PostgreSQLParser.index_column_return); PostgreSQLParser.index_column_return index_column12 = default(PostgreSQLParser.index_column_return); object CREATE1_tree = null; object UNIQUE2_tree = null; object INDEX3_tree = null; object CONCURRENTLY4_tree = null; object ON5_tree = null; object USING7_tree = null; object LPAREN9_tree = null; object COMMA11_tree = null; object RPAREN13_tree = null; try { // ..\\Plugin.postgre\\AntlrParser\\PostgreSQL.g:14:36: ( CREATE ( UNIQUE )? INDEX ( CONCURRENTLY )? name= index_name ON table_name ( USING id )? LPAREN index_column[index] ( COMMA index_column[index] )* RPAREN ) // ..\\Plugin.postgre\\AntlrParser\\PostgreSQL.g:15:5: CREATE ( UNIQUE )? INDEX ( CONCURRENTLY )? name= index_name ON table_name ( USING id )? LPAREN index_column[index] ( COMMA index_column[index] )* RPAREN { root_0 = (object)adaptor.GetNilNode(); CREATE1 = (IToken)Match(input, CREATE, FOLLOW_CREATE_in_create_index37); CREATE1_tree = (object)adaptor.Create(CREATE1); adaptor.AddChild(root_0, CREATE1_tree); // ..\\Plugin.postgre\\AntlrParser\\PostgreSQL.g:16:5: ( UNIQUE )? int alt1 = 2; int LA1_0 = input.LA(1); if ((LA1_0 == UNIQUE)) { alt1 = 1; } switch (alt1) { case 1: // ..\\Plugin.postgre\\AntlrParser\\PostgreSQL.g:16:6: UNIQUE { UNIQUE2 = (IToken)Match(input, UNIQUE, FOLLOW_UNIQUE_in_create_index44); UNIQUE2_tree = (object)adaptor.Create(UNIQUE2); adaptor.AddChild(root_0, UNIQUE2_tree); index.IsUnique = true; } break; } INDEX3 = (IToken)Match(input, INDEX, FOLLOW_INDEX_in_create_index54); INDEX3_tree = (object)adaptor.Create(INDEX3); adaptor.AddChild(root_0, INDEX3_tree); // ..\\Plugin.postgre\\AntlrParser\\PostgreSQL.g:18:5: ( CONCURRENTLY )? int alt2 = 2; int LA2_0 = input.LA(1); if ((LA2_0 == CONCURRENTLY)) { alt2 = 1; } switch (alt2) { case 1: // ..\\Plugin.postgre\\AntlrParser\\PostgreSQL.g:18:5: CONCURRENTLY { CONCURRENTLY4 = (IToken)Match(input, CONCURRENTLY, FOLLOW_CONCURRENTLY_in_create_index60); CONCURRENTLY4_tree = (object)adaptor.Create(CONCURRENTLY4); adaptor.AddChild(root_0, CONCURRENTLY4_tree); } break; } PushFollow(FOLLOW_index_name_in_create_index70); name = index_name(); state.followingStackPointer--; adaptor.AddChild(root_0, name.Tree); index.Name = UnquoteName(((name != null) ? input.ToString((IToken)(name.Start), (IToken)(name.Stop)) : null)); ON5 = (IToken)Match(input, ON, FOLLOW_ON_in_create_index79); ON5_tree = (object)adaptor.Create(ON5); adaptor.AddChild(root_0, ON5_tree); PushFollow(FOLLOW_table_name_in_create_index81); table_name6 = table_name(); state.followingStackPointer--; adaptor.AddChild(root_0, table_name6.Tree); index.SetDummyTable(((table_name6 != null) ? table_name6.result : default(NameWithSchema))); // ..\\Plugin.postgre\\AntlrParser\\PostgreSQL.g:21:5: ( USING id )? int alt3 = 2; int LA3_0 = input.LA(1); if ((LA3_0 == USING)) { alt3 = 1; } switch (alt3) { case 1: // ..\\Plugin.postgre\\AntlrParser\\PostgreSQL.g:21:6: USING id { USING7 = (IToken)Match(input, USING, FOLLOW_USING_in_create_index90); USING7_tree = (object)adaptor.Create(USING7); adaptor.AddChild(root_0, USING7_tree); PushFollow(FOLLOW_id_in_create_index92); id8 = id(); state.followingStackPointer--; adaptor.AddChild(root_0, id8.Tree); } break; } LPAREN9 = (IToken)Match(input, LPAREN, FOLLOW_LPAREN_in_create_index100); LPAREN9_tree = (object)adaptor.Create(LPAREN9); adaptor.AddChild(root_0, LPAREN9_tree); PushFollow(FOLLOW_index_column_in_create_index102); index_column10 = index_column(index); state.followingStackPointer--; adaptor.AddChild(root_0, index_column10.Tree); // ..\\Plugin.postgre\\AntlrParser\\PostgreSQL.g:22:32: ( COMMA index_column[index] )* do { int alt4 = 2; int LA4_0 = input.LA(1); if ((LA4_0 == COMMA)) { alt4 = 1; } switch (alt4) { case 1: // ..\\Plugin.postgre\\AntlrParser\\PostgreSQL.g:22:33: COMMA index_column[index] { COMMA11 = (IToken)Match(input, COMMA, FOLLOW_COMMA_in_create_index106); COMMA11_tree = (object)adaptor.Create(COMMA11); adaptor.AddChild(root_0, COMMA11_tree); PushFollow(FOLLOW_index_column_in_create_index108); index_column12 = index_column(index); state.followingStackPointer--; adaptor.AddChild(root_0, index_column12.Tree); } break; default: goto loop4; } } while (true); loop4: ; // Stops C# compiler whining that label 'loop4' has no statements RPAREN13 = (IToken)Match(input, RPAREN, FOLLOW_RPAREN_in_create_index113); RPAREN13_tree = (object)adaptor.Create(RPAREN13); adaptor.AddChild(root_0, RPAREN13_tree); } retval.Stop = input.LT(-1); retval.Tree = (object)adaptor.RulePostProcessing(root_0); adaptor.SetTokenBoundaries(retval.Tree, (IToken)retval.Start, (IToken)retval.Stop); } catch (RecognitionException re) { ReportError(re); Recover(input, re); // Conversion of the second argument necessary, but harmless retval.Tree = (object)adaptor.ErrorNode(input, (IToken)retval.Start, input.LT(-1), re); } finally { } return(retval); }
public object ParseNode() { // "%label:" prefix string label = null; if (ttype == TreePatternLexer.PERCENT) { ttype = tokenizer.NextToken(); if (ttype != TreePatternLexer.ID) { return(null); } label = tokenizer.sval.ToString(); ttype = tokenizer.NextToken(); if (ttype != TreePatternLexer.COLON) { return(null); } ttype = tokenizer.NextToken(); // move to ID following colon } // Wildcard? if (ttype == TreePatternLexer.DOT) { ttype = tokenizer.NextToken(); IToken wildcardPayload = new CommonToken(0, "."); TreeWizard.TreePattern node = new TreeWizard.WildcardTreePattern(wildcardPayload); if (label != null) { node.label = label; } return(node); } // "ID" or "ID[arg]" if (ttype != TreePatternLexer.ID) { return(null); } string tokenName = tokenizer.sval.ToString(); ttype = tokenizer.NextToken(); if (tokenName.Equals("nil")) { return(adaptor.GetNilNode()); } string text = tokenName; // check for arg string arg = null; if (ttype == TreePatternLexer.ARG) { arg = tokenizer.sval.ToString(); text = arg; ttype = tokenizer.NextToken(); } // create node int treeNodeType = wizard.GetTokenType(tokenName); if (treeNodeType == Token.INVALID_TOKEN_TYPE) { return(null); } object nodeObj; nodeObj = adaptor.Create(treeNodeType, text); if ((label != null) && (nodeObj.GetType() == typeof(TreeWizard.TreePattern))) { ((TreeWizard.TreePattern)nodeObj).label = label; } if ((arg != null) && (nodeObj.GetType() == typeof(TreeWizard.TreePattern))) { ((TreeWizard.TreePattern)nodeObj).hasTextArg = true; } return(nodeObj); }
// $ANTLR start "start" // D:\\Szkolenia\\Artykuł ProgramistaMag - DSL\\Code\\DSLSamples\\HelloWorld\\Simple.g:13:0: start : ID EOF -> ^( START ID ) ; public SimpleParser.start_return start() // throws RecognitionException [1] { SimpleParser.start_return retval = new SimpleParser.start_return(); retval.Start = input.LT(1); CommonTree root_0 = null; IToken ID1 = null; IToken EOF2 = null; CommonTree ID1_tree = null; CommonTree EOF2_tree = null; RewriteRuleTokenStream stream_ID = new RewriteRuleTokenStream(adaptor, "token ID"); RewriteRuleTokenStream stream_EOF = new RewriteRuleTokenStream(adaptor, "token EOF"); try { // D:\\Szkolenia\\Artykuł ProgramistaMag - DSL\\Code\\DSLSamples\\HelloWorld\\Simple.g:13:8: ( ID EOF -> ^( START ID ) ) // D:\\Szkolenia\\Artykuł ProgramistaMag - DSL\\Code\\DSLSamples\\HelloWorld\\Simple.g:13:8: ID EOF { ID1 = (IToken)Match(input, ID, FOLLOW_ID_in_start50); stream_ID.Add(ID1); EOF2 = (IToken)Match(input, EOF, FOLLOW_EOF_in_start52); stream_EOF.Add(EOF2); // AST REWRITE // elements: ID // token labels: // rule labels: retval // token list labels: // rule list labels: // wildcard labels: retval.Tree = root_0; RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.Tree : null); root_0 = (CommonTree)adaptor.GetNilNode(); // 13:15: -> ^( START ID ) { // D:\\Szkolenia\\Artykuł ProgramistaMag - DSL\\Code\\DSLSamples\\HelloWorld\\Simple.g:13:18: ^( START ID ) { CommonTree root_1 = (CommonTree)adaptor.GetNilNode(); root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(START, "START"), root_1); adaptor.AddChild(root_1, stream_ID.NextNode()); adaptor.AddChild(root_0, root_1); } } retval.Tree = root_0; retval.Tree = root_0; } retval.Stop = input.LT(-1); retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0); adaptor.SetTokenBoundaries(retval.Tree, (IToken)retval.Start, (IToken)retval.Stop); } catch (RecognitionException re) { ReportError(re); Recover(input, re); // Conversion of the second argument necessary, but harmless retval.Tree = (CommonTree)adaptor.ErrorNode(input, (IToken)retval.Start, input.LT(-1), re); } finally { } return(retval); }