当前位置: 首页>>代码示例>>C#>>正文


C# RewriteRuleSubtreeStream.NextNode方法代码示例

本文整理汇总了C#中RewriteRuleSubtreeStream.NextNode方法的典型用法代码示例。如果您正苦于以下问题:C# RewriteRuleSubtreeStream.NextNode方法的具体用法?C# RewriteRuleSubtreeStream.NextNode怎么用?C# RewriteRuleSubtreeStream.NextNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RewriteRuleSubtreeStream的用法示例。


在下文中一共展示了RewriteRuleSubtreeStream.NextNode方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: leftValueExpression

    // $ANTLR start "leftValueExpression"
    // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:335:1: leftValueExpression : ( leftValue | unaryPrefixAssignerOp leftValueExpression -> ^( PREFIXOP ^( unaryPrefixAssignerOp leftValueExpression ) ) );
    public PsimulexParser.leftValueExpression_return leftValueExpression() // throws RecognitionException [1]
    {   
        PsimulexParser.leftValueExpression_return retval = new PsimulexParser.leftValueExpression_return();
        retval.Start = input.LT(1);
        int leftValueExpression_StartIndex = input.Index();
        CommonTree root_0 = null;

        PsimulexParser.leftValue_return leftValue90 = default(PsimulexParser.leftValue_return);

        PsimulexParser.unaryPrefixAssignerOp_return unaryPrefixAssignerOp91 = default(PsimulexParser.unaryPrefixAssignerOp_return);

        PsimulexParser.leftValueExpression_return leftValueExpression92 = default(PsimulexParser.leftValueExpression_return);


        RewriteRuleSubtreeStream stream_leftValueExpression = new RewriteRuleSubtreeStream(adaptor,"rule leftValueExpression");
        RewriteRuleSubtreeStream stream_unaryPrefixAssignerOp = new RewriteRuleSubtreeStream(adaptor,"rule unaryPrefixAssignerOp");
        try 
    	{
    	    if ( (state.backtracking > 0) && AlreadyParsedRule(input, 38) ) 
    	    {
    	    	return retval; 
    	    }
            // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:336:2: ( leftValue | unaryPrefixAssignerOp leftValueExpression -> ^( PREFIXOP ^( unaryPrefixAssignerOp leftValueExpression ) ) )
            int alt26 = 2;
            int LA26_0 = input.LA(1);

            if ( (LA26_0 == Identifier || LA26_0 == Reference || LA26_0 == 149) )
            {
                alt26 = 1;
            }
            else if ( ((LA26_0 >= PlusPlus && LA26_0 <= MinusMinus)) )
            {
                alt26 = 2;
            }
            else 
            {
                if ( state.backtracking > 0 ) {state.failed = true; return retval;}
                NoViableAltException nvae_d26s0 =
                    new NoViableAltException("", 26, 0, input);

                throw nvae_d26s0;
            }
            switch (alt26) 
            {
                case 1 :
                    // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:336:4: leftValue
                    {
                    	root_0 = (CommonTree)adaptor.GetNilNode();

                    	PushFollow(FOLLOW_leftValue_in_leftValueExpression1565);
                    	leftValue90 = leftValue();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	if ( state.backtracking == 0 ) adaptor.AddChild(root_0, leftValue90.Tree);

                    }
                    break;
                case 2 :
                    // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:337:4: unaryPrefixAssignerOp leftValueExpression
                    {
                    	PushFollow(FOLLOW_unaryPrefixAssignerOp_in_leftValueExpression1570);
                    	unaryPrefixAssignerOp91 = unaryPrefixAssignerOp();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	if ( (state.backtracking==0) ) stream_unaryPrefixAssignerOp.Add(unaryPrefixAssignerOp91.Tree);
                    	PushFollow(FOLLOW_leftValueExpression_in_leftValueExpression1572);
                    	leftValueExpression92 = leftValueExpression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	if ( (state.backtracking==0) ) stream_leftValueExpression.Add(leftValueExpression92.Tree);


                    	// AST REWRITE
                    	// elements:          unaryPrefixAssignerOp, leftValueExpression
                    	// token labels:      
                    	// rule labels:       retval
                    	// token list labels: 
                    	// rule list labels:  
                    	// wildcard labels: 
                    	if ( (state.backtracking==0) ) {
                    	retval.Tree = root_0;
                    	RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null);

                    	root_0 = (CommonTree)adaptor.GetNilNode();
                    	// 337:46: -> ^( PREFIXOP ^( unaryPrefixAssignerOp leftValueExpression ) )
                    	{
                    	    // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:337:49: ^( PREFIXOP ^( unaryPrefixAssignerOp leftValueExpression ) )
                    	    {
                    	    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                    	    root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(PREFIXOP, "PREFIXOP"), root_1);

                    	    // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:337:61: ^( unaryPrefixAssignerOp leftValueExpression )
                    	    {
                    	    CommonTree root_2 = (CommonTree)adaptor.GetNilNode();
                    	    root_2 = (CommonTree)adaptor.BecomeRoot(stream_unaryPrefixAssignerOp.NextNode(), root_2);

                    	    adaptor.AddChild(root_2, stream_leftValueExpression.NextTree());

//.........这里部分代码省略.........
开发者ID:hunpody,项目名称:psimulex,代码行数:101,代码来源:PsimulexParser.cs

示例2: varsDecl


//.........这里部分代码省略.........
					if (state.backtracking == 0) stream_varDecl.Add(varDecl54.Tree);

					}
					break;

				default:
					goto loop14;
				}
			}

			loop14:
				;

			} finally { DebugExitSubRule(14); }



			{
			// AST REWRITE
			// elements: varDecl, ident
			// token labels: 
			// rule labels: retval
			// token list labels: 
			// rule list labels: 
			// wildcard labels: 
			if (state.backtracking == 0) {
			retval.Tree = root_0;
			RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);

			root_0 = (object)adaptor.Nil();
			// 213:42: -> ^( VAR ^( ident ( varDecl )+ ) )
			{
				DebugLocation(213, 45);
				// CCompiler.g:213:45: ^( VAR ^( ident ( varDecl )+ ) )
				{
				object root_1 = (object)adaptor.Nil();
				DebugLocation(213, 47);
				root_1 = (object)adaptor.BecomeRoot((object)adaptor.Create(VAR, "VAR"), root_1);

				DebugLocation(213, 51);
				// CCompiler.g:213:51: ^( ident ( varDecl )+ )
				{
				object root_2 = (object)adaptor.Nil();
				DebugLocation(213, 53);
				root_2 = (object)adaptor.BecomeRoot(stream_ident.NextNode(), root_2);

				DebugLocation(213, 59);
				if (!(stream_varDecl.HasNext))
				{
					throw new RewriteEarlyExitException();
				}
				while ( stream_varDecl.HasNext )
				{
					DebugLocation(213, 59);
					adaptor.AddChild(root_2, stream_varDecl.NextTree());

				}
				stream_varDecl.Reset();

				adaptor.AddChild(root_1, root_2);
				}

				adaptor.AddChild(root_0, root_1);
				}

			}

			retval.Tree = root_0;
			}
			}

			}

			retval.Stop = (IToken)input.LT(-1);

			if (state.backtracking == 0) {
			retval.Tree = (object)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);
			}
		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		retval.Tree = (object)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("varsDecl", 18);
			LeaveRule("varsDecl", 18);
			LeaveRule_varsDecl();
			if (state.backtracking > 0) { Memoize(input, 18, varsDecl_StartIndex); }

		}
		DebugLocation(213, 69);
		} finally { DebugExitRule(GrammarFileName, "varsDecl"); }
		return retval;

	}
开发者ID:chursin-andrey,项目名称:CCompiler,代码行数:101,代码来源:CCompilerParser.cs

示例3: unaryPrefixExpression

    // $ANTLR start "unaryPrefixExpression"
    // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:326:1: unaryPrefixExpression : unaryPrefixOp unaryExpression -> ^( PREFIXOP ^( unaryPrefixOp unaryExpression ) ) ;
    public PsimulexParser.unaryPrefixExpression_return unaryPrefixExpression() // throws RecognitionException [1]
    {   
        PsimulexParser.unaryPrefixExpression_return retval = new PsimulexParser.unaryPrefixExpression_return();
        retval.Start = input.LT(1);
        int unaryPrefixExpression_StartIndex = input.Index();
        CommonTree root_0 = null;

        PsimulexParser.unaryPrefixOp_return unaryPrefixOp85 = default(PsimulexParser.unaryPrefixOp_return);

        PsimulexParser.unaryExpression_return unaryExpression86 = default(PsimulexParser.unaryExpression_return);


        RewriteRuleSubtreeStream stream_unaryPrefixOp = new RewriteRuleSubtreeStream(adaptor,"rule unaryPrefixOp");
        RewriteRuleSubtreeStream stream_unaryExpression = new RewriteRuleSubtreeStream(adaptor,"rule unaryExpression");
        try 
    	{
    	    if ( (state.backtracking > 0) && AlreadyParsedRule(input, 36) ) 
    	    {
    	    	return retval; 
    	    }
            // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:327:2: ( unaryPrefixOp unaryExpression -> ^( PREFIXOP ^( unaryPrefixOp unaryExpression ) ) )
            // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:327:4: unaryPrefixOp unaryExpression
            {
            	PushFollow(FOLLOW_unaryPrefixOp_in_unaryPrefixExpression1511);
            	unaryPrefixOp85 = unaryPrefixOp();
            	state.followingStackPointer--;
            	if (state.failed) return retval;
            	if ( (state.backtracking==0) ) stream_unaryPrefixOp.Add(unaryPrefixOp85.Tree);
            	PushFollow(FOLLOW_unaryExpression_in_unaryPrefixExpression1513);
            	unaryExpression86 = unaryExpression();
            	state.followingStackPointer--;
            	if (state.failed) return retval;
            	if ( (state.backtracking==0) ) stream_unaryExpression.Add(unaryExpression86.Tree);


            	// AST REWRITE
            	// elements:          unaryPrefixOp, unaryExpression
            	// token labels:      
            	// rule labels:       retval
            	// token list labels: 
            	// rule list labels:  
            	// wildcard labels: 
            	if ( (state.backtracking==0) ) {
            	retval.Tree = root_0;
            	RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null);

            	root_0 = (CommonTree)adaptor.GetNilNode();
            	// 327:34: -> ^( PREFIXOP ^( unaryPrefixOp unaryExpression ) )
            	{
            	    // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:327:37: ^( PREFIXOP ^( unaryPrefixOp unaryExpression ) )
            	    {
            	    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
            	    root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(PREFIXOP, "PREFIXOP"), root_1);

            	    // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:327:49: ^( unaryPrefixOp unaryExpression )
            	    {
            	    CommonTree root_2 = (CommonTree)adaptor.GetNilNode();
            	    root_2 = (CommonTree)adaptor.BecomeRoot(stream_unaryPrefixOp.NextNode(), root_2);

            	    adaptor.AddChild(root_2, stream_unaryExpression.NextTree());

            	    adaptor.AddChild(root_1, root_2);
            	    }

            	    adaptor.AddChild(root_0, root_1);
            	    }

            	}

            	retval.Tree = root_0;retval.Tree = root_0;}
            }

            retval.Stop = input.LT(-1);

            if ( (state.backtracking==0) )
            {	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 
    	{
            if ( state.backtracking > 0 ) 
            {
            	Memoize(input, 36, unaryPrefixExpression_StartIndex); 
            }
        }
        return retval;
    }
开发者ID:hunpody,项目名称:psimulex,代码行数:97,代码来源:PsimulexParser.cs

示例4: when


//.........这里部分代码省略.........
            	    switch (alt103) 
            		{
            			case 1 :
            			    // C:\\nadir\\nadir\\Nadir\\Parsing\\Nadir.g:750:67: s+= seqDesignInterior
            			    {
            			    	PushFollow(FOLLOW_seqDesignInterior_in_when13909);
            			    	s = seqDesignInterior();
            			    	state.followingStackPointer--;
            			    	if (state.failed) return retval;
            			    	if ( (state.backtracking==0) ) stream_seqDesignInterior.Add(s.Tree);
            			    	if (list_s == null) list_s = new ArrayList();
            			    	list_s.Add(s.Tree);


            			    }
            			    break;

            			default:
            			    goto loop103;
            	    }
            	} while (true);

            	loop103:
            		;	// Stops C# compiler whining that label 'loop103' has no statements

            	char_literal315=(NadirToken)Match(input,156,FOLLOW_156_in_when13912); if (state.failed) return retval; 
            	if ( (state.backtracking==0) ) stream_156.Add(char_literal315);



            	// AST REWRITE
            	// elements:          whenApplicability, s, whenGuard
            	// token labels:      
            	// rule labels:       retval
            	// token list labels: 
            	// rule list labels:  s
            	// wildcard labels: 
            	if ( (state.backtracking==0) ) {
            	retval.Tree = root_0;
            	RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null);
            	RewriteRuleSubtreeStream stream_s = new RewriteRuleSubtreeStream(adaptor, "token s", list_s);
            	root_0 = (NadirAST)adaptor.GetNilNode();
            	// 751:17: -> ^( whenApplicability whenGuard ( $s)* )
            	{
            	    // C:\\nadir\\nadir\\Nadir\\Parsing\\Nadir.g:751:20: ^( whenApplicability whenGuard ( $s)* )
            	    {
            	    NadirAST root_1 = (NadirAST)adaptor.GetNilNode();
            	    root_1 = (NadirAST)adaptor.BecomeRoot(stream_whenApplicability.NextNode(), root_1);

            	    adaptor.AddChild(root_1, stream_whenGuard.NextTree());
            	    // C:\\nadir\\nadir\\Nadir\\Parsing\\Nadir.g:751:50: ( $s)*
            	    while ( stream_s.HasNext() )
            	    {
            	        adaptor.AddChild(root_1, stream_s.NextTree());

            	    }
            	    stream_s.Reset();

            	    adaptor.AddChild(root_0, root_1);
            	    }

            	}

            	retval.Tree = root_0;retval.Tree = root_0;}
            }

            retval.Stop = input.LT(-1);

            if ( (state.backtracking==0) )
            {	retval.Tree = (NadirAST)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);}
        }

            // We do this manually to specifically catch the NON RecognitionExceptions that might 
            // be thrown, like RewriteEarlyExitExceptions. Note we use 're' as the exception variable name
            // as that's what Antlr has been using all along, and thus won't conflict with other locals.
            catch (NadirRuntimeException re)
                {
                throw new LocatedRuntimeException(re, (IToken)retval.Start, input.LT(-1));      // input.LT(-1) is inspired by the clause below
                }
            catch (RecognitionException re) 
                {
                ReportError(re);
                Recover(input,re);

                // The following is taken verbatim from what was being emitted automatically before
                // we took over manual control here. We're not certain what it does.
                //
                // "Conversion of the second argument necessary, but harmless"
                retval.Tree = (NadirAST)adaptor.ErrorNode(input, /*token start*/(IToken)retval.Start, /*token stop*/input.LT(-1), re);
                }
            catch (Exception re)
                {
                throw new LocatedException(re, (IToken)retval.Start, input.LT(-1));             // input.LT(-1) is inspired by the clause above
                }
                finally 
    	{
        }
        return retval;
    }
开发者ID:rgatkinson,项目名称:nadir,代码行数:101,代码来源:NadirParser.cs

示例5: ntDistribution

    // $ANTLR start "ntDistribution"
    // C:\\nadir\\nadir\\Nadir\\Parsing\\Nadir.g:741:1: ntDistribution : nt ':' expression -> ^( nt expression ) ;
    public NadirParser.ntDistribution_return ntDistribution() // throws RecognitionException [1]
    {   
        NadirParser.ntDistribution_return retval = new NadirParser.ntDistribution_return();
        retval.Start = input.LT(1);

        NadirAST root_0 = null;

        NadirToken char_literal309 = null;
        NadirParser.nt_return nt308 = default(NadirParser.nt_return);

        NadirParser.expression_return expression310 = default(NadirParser.expression_return);


        NadirAST char_literal309_tree=null;
        RewriteRuleTokenStream stream_179 = new RewriteRuleTokenStream(adaptor,"token 179");
        RewriteRuleSubtreeStream stream_expression = new RewriteRuleSubtreeStream(adaptor,"rule expression");
        RewriteRuleSubtreeStream stream_nt = new RewriteRuleSubtreeStream(adaptor,"rule nt");
        try 
    	{
            // C:\\nadir\\nadir\\Nadir\\Parsing\\Nadir.g:742:9: ( nt ':' expression -> ^( nt expression ) )
            // C:\\nadir\\nadir\\Nadir\\Parsing\\Nadir.g:742:17: nt ':' expression
            {
            	PushFollow(FOLLOW_nt_in_ntDistribution13763);
            	nt308 = nt();
            	state.followingStackPointer--;
            	if (state.failed) return retval;
            	if ( (state.backtracking==0) ) stream_nt.Add(nt308.Tree);
            	char_literal309=(NadirToken)Match(input,179,FOLLOW_179_in_ntDistribution13765); if (state.failed) return retval; 
            	if ( (state.backtracking==0) ) stream_179.Add(char_literal309);

            	PushFollow(FOLLOW_expression_in_ntDistribution13767);
            	expression310 = expression();
            	state.followingStackPointer--;
            	if (state.failed) return retval;
            	if ( (state.backtracking==0) ) stream_expression.Add(expression310.Tree);


            	// AST REWRITE
            	// elements:          expression, nt
            	// token labels:      
            	// rule labels:       retval
            	// token list labels: 
            	// rule list labels:  
            	// wildcard labels: 
            	if ( (state.backtracking==0) ) {
            	retval.Tree = root_0;
            	RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null);

            	root_0 = (NadirAST)adaptor.GetNilNode();
            	// 742:73: -> ^( nt expression )
            	{
            	    // C:\\nadir\\nadir\\Nadir\\Parsing\\Nadir.g:742:76: ^( nt expression )
            	    {
            	    NadirAST root_1 = (NadirAST)adaptor.GetNilNode();
            	    root_1 = (NadirAST)adaptor.BecomeRoot(stream_nt.NextNode(), root_1);

            	    adaptor.AddChild(root_1, stream_expression.NextTree());

            	    adaptor.AddChild(root_0, root_1);
            	    }

            	}

            	retval.Tree = root_0;retval.Tree = root_0;}
            }

            retval.Stop = input.LT(-1);

            if ( (state.backtracking==0) )
            {	retval.Tree = (NadirAST)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);}
        }

            // We do this manually to specifically catch the NON RecognitionExceptions that might 
            // be thrown, like RewriteEarlyExitExceptions. Note we use 're' as the exception variable name
            // as that's what Antlr has been using all along, and thus won't conflict with other locals.
            catch (NadirRuntimeException re)
                {
                throw new LocatedRuntimeException(re, (IToken)retval.Start, input.LT(-1));      // input.LT(-1) is inspired by the clause below
                }
            catch (RecognitionException re) 
                {
                ReportError(re);
                Recover(input,re);

                // The following is taken verbatim from what was being emitted automatically before
                // we took over manual control here. We're not certain what it does.
                //
                // "Conversion of the second argument necessary, but harmless"
                retval.Tree = (NadirAST)adaptor.ErrorNode(input, /*token start*/(IToken)retval.Start, /*token stop*/input.LT(-1), re);
                }
            catch (Exception re)
                {
                throw new LocatedException(re, (IToken)retval.Start, input.LT(-1));             // input.LT(-1) is inspired by the clause above
                }
                finally 
    	{
        }
//.........这里部分代码省略.........
开发者ID:rgatkinson,项目名称:nadir,代码行数:101,代码来源:NadirParser.cs

示例6: unaryExpression


//.........这里部分代码省略.........
                    	RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null);

                    	root_0 = (NadirAST)adaptor.GetNilNode();
                    	// 502:49: -> ^( PreMinusMinus[$loc] castExpression )
                    	{
                    	    // C:\\nadir\\nadir\\Nadir\\Parsing\\Nadir.g:502:52: ^( PreMinusMinus[$loc] castExpression )
                    	    {
                    	    NadirAST root_1 = (NadirAST)adaptor.GetNilNode();
                    	    root_1 = (NadirAST)adaptor.BecomeRoot((NadirAST)adaptor.Create(PreMinusMinus, loc), root_1);

                    	    adaptor.AddChild(root_1, stream_castExpression.NextTree());

                    	    adaptor.AddChild(root_0, root_1);
                    	    }

                    	}

                    	retval.Tree = root_0;retval.Tree = root_0;}
                    }
                    break;
                case 4 :
                    // C:\\nadir\\nadir\\Nadir\\Parsing\\Nadir.g:503:14: unaryOperator castExpression
                    {
                    	PushFollow(FOLLOW_unaryOperator_in_unaryExpression9863);
                    	unaryOperator188 = unaryOperator();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	if ( (state.backtracking==0) ) stream_unaryOperator.Add(unaryOperator188.Tree);
                    	PushFollow(FOLLOW_castExpression_in_unaryExpression9865);
                    	castExpression189 = castExpression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	if ( (state.backtracking==0) ) stream_castExpression.Add(castExpression189.Tree);


                    	// AST REWRITE
                    	// elements:          castExpression, unaryOperator
                    	// token labels:      
                    	// rule labels:       retval
                    	// token list labels: 
                    	// rule list labels:  
                    	// wildcard labels: 
                    	if ( (state.backtracking==0) ) {
                    	retval.Tree = root_0;
                    	RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null);

                    	root_0 = (NadirAST)adaptor.GetNilNode();
                    	// 503:49: -> ^( unaryOperator castExpression )
                    	{
                    	    // C:\\nadir\\nadir\\Nadir\\Parsing\\Nadir.g:503:52: ^( unaryOperator castExpression )
                    	    {
                    	    NadirAST root_1 = (NadirAST)adaptor.GetNilNode();
                    	    root_1 = (NadirAST)adaptor.BecomeRoot(stream_unaryOperator.NextNode(), root_1);

                    	    adaptor.AddChild(root_1, stream_castExpression.NextTree());

                    	    adaptor.AddChild(root_0, root_1);
                    	    }

                    	}

                    	retval.Tree = root_0;retval.Tree = root_0;}
                    }
                    break;

            }
            retval.Stop = input.LT(-1);

            if ( (state.backtracking==0) )
            {	retval.Tree = (NadirAST)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);}
        }

            // We do this manually to specifically catch the NON RecognitionExceptions that might 
            // be thrown, like RewriteEarlyExitExceptions. Note we use 're' as the exception variable name
            // as that's what Antlr has been using all along, and thus won't conflict with other locals.
            catch (NadirRuntimeException re)
                {
                throw new LocatedRuntimeException(re, (IToken)retval.Start, input.LT(-1));      // input.LT(-1) is inspired by the clause below
                }
            catch (RecognitionException re) 
                {
                ReportError(re);
                Recover(input,re);

                // The following is taken verbatim from what was being emitted automatically before
                // we took over manual control here. We're not certain what it does.
                //
                // "Conversion of the second argument necessary, but harmless"
                retval.Tree = (NadirAST)adaptor.ErrorNode(input, /*token start*/(IToken)retval.Start, /*token stop*/input.LT(-1), re);
                }
            catch (Exception re)
                {
                throw new LocatedException(re, (IToken)retval.Start, input.LT(-1));             // input.LT(-1) is inspired by the clause above
                }
                finally 
    	{
        }
        return retval;
    }
开发者ID:rgatkinson,项目名称:nadir,代码行数:101,代码来源:NadirParser.cs

示例7: expression

    // $ANTLR start "expression"
    // D:\\development\\Less.Net\\lesscss.g:52:10: fragment expression : additiveExpression -> ^( EXPR ^( additiveExpression ) ) ;
    public lesscssParser.expression_return expression() // throws RecognitionException [1]
    {   
        lesscssParser.expression_return retval = new lesscssParser.expression_return();
        retval.Start = input.LT(1);

        CommonTree root_0 = null;

        lesscssParser.additiveExpression_return additiveExpression16 = default(lesscssParser.additiveExpression_return);


        RewriteRuleSubtreeStream stream_additiveExpression = new RewriteRuleSubtreeStream(adaptor,"rule additiveExpression");
        try 
    	{
            // D:\\development\\Less.Net\\lesscss.g:53:2: ( additiveExpression -> ^( EXPR ^( additiveExpression ) ) )
            // D:\\development\\Less.Net\\lesscss.g:53:5: additiveExpression
            {
            	PushFollow(FOLLOW_additiveExpression_in_expression268);
            	additiveExpression16 = additiveExpression();
            	state.followingStackPointer--;

            	stream_additiveExpression.Add(additiveExpression16.Tree);


            	// AST REWRITE
            	// elements:          additiveExpression
            	// 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();
            	// 53:24: -> ^( EXPR ^( additiveExpression ) )
            	{
            	    // D:\\development\\Less.Net\\lesscss.g:53:27: ^( EXPR ^( additiveExpression ) )
            	    {
            	    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
            	    root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(EXPR, "EXPR"), root_1);

            	    // D:\\development\\Less.Net\\lesscss.g:53:34: ^( additiveExpression )
            	    {
            	    CommonTree root_2 = (CommonTree)adaptor.GetNilNode();
            	    root_2 = (CommonTree)adaptor.BecomeRoot(stream_additiveExpression.NextNode(), root_2);

            	    adaptor.AddChild(root_1, root_2);
            	    }

            	    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;
    }
开发者ID:erikvanbrakel,项目名称:less.net,代码行数:77,代码来源:lesscssParser.cs

示例8: lessLine

    // $ANTLR start "lessLine"
    // D:\\development\\Less.Net\\lesscss.g:37:10: fragment lessLine : ( ruleset -> ^( ruleset ) | mediadefinition -> ^( mediadefinition ) | variable -> ^( variable ) );
    public lesscssParser.lessLine_return lessLine() // throws RecognitionException [1]
    {   
        lesscssParser.lessLine_return retval = new lesscssParser.lessLine_return();
        retval.Start = input.LT(1);

        CommonTree root_0 = null;

        lesscssParser.ruleset_return ruleset8 = default(lesscssParser.ruleset_return);

        lesscssParser.mediadefinition_return mediadefinition9 = default(lesscssParser.mediadefinition_return);

        lesscssParser.variable_return variable10 = default(lesscssParser.variable_return);


        RewriteRuleSubtreeStream stream_ruleset = new RewriteRuleSubtreeStream(adaptor,"rule ruleset");
        RewriteRuleSubtreeStream stream_mediadefinition = new RewriteRuleSubtreeStream(adaptor,"rule mediadefinition");
        RewriteRuleSubtreeStream stream_variable = new RewriteRuleSubtreeStream(adaptor,"rule variable");
        try 
    	{
            // D:\\development\\Less.Net\\lesscss.g:38:2: ( ruleset -> ^( ruleset ) | mediadefinition -> ^( mediadefinition ) | variable -> ^( variable ) )
            int alt3 = 3;
            switch ( input.LA(1) ) 
            {
            case IDENT:
            case 49:
            case 50:
            	{
                alt3 = 1;
                }
                break;
            case 36:
            	{
                alt3 = 2;
                }
                break;
            case 26:
            	{
                alt3 = 3;
                }
                break;
            	default:
            	    NoViableAltException nvae_d3s0 =
            	        new NoViableAltException("", 3, 0, input);

            	    throw nvae_d3s0;
            }

            switch (alt3) 
            {
                case 1 :
                    // D:\\development\\Less.Net\\lesscss.g:38:4: ruleset
                    {
                    	PushFollow(FOLLOW_ruleset_in_lessLine172);
                    	ruleset8 = ruleset();
                    	state.followingStackPointer--;

                    	stream_ruleset.Add(ruleset8.Tree);


                    	// AST REWRITE
                    	// elements:          ruleset
                    	// 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();
                    	// 38:12: -> ^( ruleset )
                    	{
                    	    // D:\\development\\Less.Net\\lesscss.g:38:15: ^( ruleset )
                    	    {
                    	    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                    	    root_1 = (CommonTree)adaptor.BecomeRoot(stream_ruleset.NextNode(), root_1);

                    	    adaptor.AddChild(root_0, root_1);
                    	    }

                    	}

                    	retval.Tree = root_0;retval.Tree = root_0;
                    }
                    break;
                case 2 :
                    // D:\\development\\Less.Net\\lesscss.g:38:28: mediadefinition
                    {
                    	PushFollow(FOLLOW_mediadefinition_in_lessLine182);
                    	mediadefinition9 = mediadefinition();
                    	state.followingStackPointer--;

                    	stream_mediadefinition.Add(mediadefinition9.Tree);


                    	// AST REWRITE
                    	// elements:          mediadefinition
                    	// token labels:      
//.........这里部分代码省略.........
开发者ID:erikvanbrakel,项目名称:less.net,代码行数:101,代码来源:lesscssParser.cs


注:本文中的RewriteRuleSubtreeStream.NextNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。