public void CheckRRSubtreeStreamBehaviourWithElements()
        {
            RewriteRuleSubtreeStream subtreeTest =
                new RewriteRuleSubtreeStream(CreateTreeAdaptor(),
                                             "RewriteRuleSubtreeStream test");

            IToken token1 = CreateToken(1, "test token without any real context");
            ITree  tree1  = CreateTree(token1);

            // Test Add()
            subtreeTest.Add(tree1);
            Assert.AreEqual(1, subtreeTest.Size(), "subtreeTest should have the size 1 (1).");
            Assert.IsTrue(subtreeTest.HasNext(), "HasNext() should be true here (1).");

            // Test NextNode()
            Assert.AreEqual(tree1, (ITree)subtreeTest.NextNode(),
                            "The returned tree should be equal to the given tree (1).");
            Assert.AreEqual(1, subtreeTest.Size(), "subtreeTest should have the size 1 (2).");
            Assert.IsFalse(subtreeTest.HasNext(), "HasNext() should be false here (1).");
            subtreeTest.Reset();
            Assert.AreEqual(1, subtreeTest.Size(), "subtreeTest should have the size 1 (3).");
            Assert.IsTrue(subtreeTest.HasNext(), "HasNext() should be true here (2).");

            // Test NextTree()
            CommonTree returnedTree = (CommonTree)subtreeTest.NextTree();

            Assert.AreEqual(token1, returnedTree.Token,
                            "The returned token should be equal to the given token (3).");
            Assert.AreEqual(1, subtreeTest.Size(), "subtreeTest should have the size 1 (4).");
            Assert.IsFalse(subtreeTest.HasNext(), "HasNext() should be false here (2).");
            subtreeTest.Reset();
            Assert.AreEqual(1, subtreeTest.Size(), "subtreeTest should have the size 1 (5).");
            Assert.IsTrue(subtreeTest.HasNext(), "HasNext() should be true here (3).");

            // Test, what happens with two elements
            IToken token2 = CreateToken(2, "test token without any real context");
            ITree  tree2  = CreateTree(token2);

            subtreeTest.Add(tree2);
            Assert.AreEqual(2, subtreeTest.Size(), "subtreeTest should have the size 2 (1).");
            Assert.IsTrue(subtreeTest.HasNext(), "HasNext() should be true here (4).");
            returnedTree = (CommonTree)subtreeTest.NextTree();
            Assert.AreEqual(token1, returnedTree.Token,
                            "The returned token should be equal to the given token (4).");
            Assert.AreEqual(2, subtreeTest.Size(), "subtreeTest should have the size 2 (2).");
            Assert.IsTrue(subtreeTest.HasNext(), "HasNext() should be true here (5).");
            returnedTree = (CommonTree)subtreeTest.NextTree();
            Assert.AreEqual(token2, returnedTree.Token,
                            "The returned token should be equal to the given token (5).");
            Assert.IsFalse(subtreeTest.HasNext(), "HasNext() should be false here (3).");

            // Test exception
            subtreeTest.NextTree();
        }
        public void CheckRRSubtreeStreamBehaviourWhileEmpty1()
        {
            string description = "RewriteRuleSubtreeStream test";
            RewriteRuleSubtreeStream subtreeTest =
                new RewriteRuleSubtreeStream(CreateTreeAdaptor(), description);

            Assert.IsFalse(subtreeTest.HasNext(), "HasNext() has to give back false here.");
            Assert.AreEqual(description.ToString(), subtreeTest.Description,
                            "Description strings should be equal.");
            Assert.AreEqual(0, subtreeTest.Size(), "The number of elements should be zero.");
            subtreeTest.Reset();
            Assert.IsTrue(true, "Reset() shouldn't make any problems here.");
            Assert.AreEqual(0, subtreeTest.Size(),
                            "The number of elements should be still zero.");
            subtreeTest.NextNode();
        }
Beispiel #3
0
    // $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());

                    	    adaptor.AddChild(root_1, root_2);
                    	    }

                    	    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 = (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, 38, leftValueExpression_StartIndex); 
            }
        }
        return retval;
    }
Beispiel #4
0
    // $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;
    }
	private AstParserRuleReturnScope<object, IToken> varsDecl()
	{
		EnterRule_varsDecl();
		EnterRule("varsDecl", 18);
		TraceIn("varsDecl", 18);
		AstParserRuleReturnScope<object, IToken> retval = new AstParserRuleReturnScope<object, IToken>();
		retval.Start = (IToken)input.LT(1);
		int varsDecl_StartIndex = input.Index;

		object root_0 = default(object);

		IToken char_literal53 = default(IToken);
		AstParserRuleReturnScope<object, IToken> ident51 = default(AstParserRuleReturnScope<object, IToken>);
		AstParserRuleReturnScope<object, IToken> varDecl52 = default(AstParserRuleReturnScope<object, IToken>);
		AstParserRuleReturnScope<object, IToken> varDecl54 = default(AstParserRuleReturnScope<object, IToken>);

		object char_literal53_tree = default(object);
		RewriteRuleITokenStream stream_COMMA=new RewriteRuleITokenStream(adaptor,"token COMMA");
		RewriteRuleSubtreeStream stream_ident=new RewriteRuleSubtreeStream(adaptor,"rule ident");
		RewriteRuleSubtreeStream stream_varDecl=new RewriteRuleSubtreeStream(adaptor,"rule varDecl");
		try { DebugEnterRule(GrammarFileName, "varsDecl");
		DebugLocation(213, 69);
		try
		{
			if (state.backtracking > 0 && AlreadyParsedRule(input, 18)) { return retval; }

			// CCompiler.g:213:9: ( ident varDecl ( ',' varDecl )* -> ^( VAR ^( ident ( varDecl )+ ) ) )
			DebugEnterAlt(1);
			// CCompiler.g:213:11: ident varDecl ( ',' varDecl )*
			{
			DebugLocation(213, 11);
			PushFollow(Follow._ident_in_varsDecl1386);
			ident51=ident();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_ident.Add(ident51.Tree);
			DebugLocation(213, 17);
			PushFollow(Follow._varDecl_in_varsDecl1388);
			varDecl52=varDecl();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_varDecl.Add(varDecl52.Tree);
			DebugLocation(213, 25);
			// CCompiler.g:213:25: ( ',' varDecl )*
			try { DebugEnterSubRule(14);
			while (true)
			{
				int alt14=2;
				try { DebugEnterDecision(14, false);
				int LA14_0 = input.LA(1);

				if ((LA14_0==COMMA))
				{
					int LA14_2 = input.LA(2);

					if ((LA14_2==IDENT))
					{
						int LA14_3 = input.LA(3);

						if ((EvaluatePredicate(synpred25_CCompiler_fragment)))
						{
							alt14 = 1;
						}


					}


				}


				} finally { DebugExitDecision(14); }
				switch ( alt14 )
				{
				case 1:
					DebugEnterAlt(1);
					// CCompiler.g:213:27: ',' varDecl
					{
					DebugLocation(213, 27);
					char_literal53=(IToken)Match(input,COMMA,Follow._COMMA_in_varsDecl1392); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_COMMA.Add(char_literal53);

					DebugLocation(213, 31);
					PushFollow(Follow._varDecl_in_varsDecl1394);
					varDecl54=varDecl();
					PopFollow();
					if (state.failed) return retval;
					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;

	}
Beispiel #6
0
    // $ANTLR start "when"
    // C:\\nadir\\nadir\\Nadir\\Parsing\\Nadir.g:749:1: when : l= 'when' whenApplicability[$l] whenGuard[$l] '{' (s+= seqDesignInterior )* '}' -> ^( whenApplicability whenGuard ( $s)* ) ;
    public NadirParser.when_return when() // throws RecognitionException [1]
    {   
        NadirParser.when_return retval = new NadirParser.when_return();
        retval.Start = input.LT(1);

        NadirAST root_0 = null;

        NadirToken l = null;
        NadirToken char_literal314 = null;
        NadirToken char_literal315 = null;
        IList list_s = null;
        NadirParser.whenApplicability_return whenApplicability312 = default(NadirParser.whenApplicability_return);

        NadirParser.whenGuard_return whenGuard313 = default(NadirParser.whenGuard_return);

        NadirParser.seqDesignInterior_return s = default(NadirParser.seqDesignInterior_return);
         s = null;
        NadirAST l_tree=null;
        NadirAST char_literal314_tree=null;
        NadirAST char_literal315_tree=null;
        RewriteRuleTokenStream stream_250 = new RewriteRuleTokenStream(adaptor,"token 250");
        RewriteRuleTokenStream stream_156 = new RewriteRuleTokenStream(adaptor,"token 156");
        RewriteRuleTokenStream stream_155 = new RewriteRuleTokenStream(adaptor,"token 155");
        RewriteRuleSubtreeStream stream_whenGuard = new RewriteRuleSubtreeStream(adaptor,"rule whenGuard");
        RewriteRuleSubtreeStream stream_whenApplicability = new RewriteRuleSubtreeStream(adaptor,"rule whenApplicability");
        RewriteRuleSubtreeStream stream_seqDesignInterior = new RewriteRuleSubtreeStream(adaptor,"rule seqDesignInterior");
        try 
    	{
            // C:\\nadir\\nadir\\Nadir\\Parsing\\Nadir.g:750:9: (l= 'when' whenApplicability[$l] whenGuard[$l] '{' (s+= seqDesignInterior )* '}' -> ^( whenApplicability whenGuard ( $s)* ) )
            // C:\\nadir\\nadir\\Nadir\\Parsing\\Nadir.g:750:17: l= 'when' whenApplicability[$l] whenGuard[$l] '{' (s+= seqDesignInterior )* '}'
            {
            	l=(NadirToken)Match(input,250,FOLLOW_250_in_when13897); if (state.failed) return retval; 
            	if ( (state.backtracking==0) ) stream_250.Add(l);

            	PushFollow(FOLLOW_whenApplicability_in_when13899);
            	whenApplicability312 = whenApplicability(l);
            	state.followingStackPointer--;
            	if (state.failed) return retval;
            	if ( (state.backtracking==0) ) stream_whenApplicability.Add(whenApplicability312.Tree);
            	PushFollow(FOLLOW_whenGuard_in_when13902);
            	whenGuard313 = whenGuard(l);
            	state.followingStackPointer--;
            	if (state.failed) return retval;
            	if ( (state.backtracking==0) ) stream_whenGuard.Add(whenGuard313.Tree);
            	char_literal314=(NadirToken)Match(input,155,FOLLOW_155_in_when13905); if (state.failed) return retval; 
            	if ( (state.backtracking==0) ) stream_155.Add(char_literal314);

            	// C:\\nadir\\nadir\\Nadir\\Parsing\\Nadir.g:750:67: (s+= seqDesignInterior )*
            	do 
            	{
            	    int alt103 = 2;
            	    int LA103_0 = input.LA(1);

            	    if ( (LA103_0 == 197 || LA103_0 == 199 || (LA103_0 >= 228 && LA103_0 <= 229) || LA103_0 == 249) )
            	    {
            	        alt103 = 1;
            	    }


            	    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;
    }
Beispiel #7
0
    // $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 
    	{
        }
        return retval;
    }
Beispiel #8
0
    // $ANTLR start "unaryExpression"
    // C:\\nadir\\nadir\\Nadir\\Parsing\\Nadir.g:499:1: unaryExpression : ( postfixExpression | loc= '++' castExpression -> ^( PrePlusPlus[$loc] castExpression ) | loc= '--' castExpression -> ^( PreMinusMinus[$loc] castExpression ) | unaryOperator castExpression -> ^( unaryOperator castExpression ) );
    public NadirParser.unaryExpression_return unaryExpression() // throws RecognitionException [1]
    {   
        NadirParser.unaryExpression_return retval = new NadirParser.unaryExpression_return();
        retval.Start = input.LT(1);

        NadirAST root_0 = null;

        NadirToken loc = null;
        NadirParser.postfixExpression_return postfixExpression185 = default(NadirParser.postfixExpression_return);

        NadirParser.castExpression_return castExpression186 = default(NadirParser.castExpression_return);

        NadirParser.castExpression_return castExpression187 = default(NadirParser.castExpression_return);

        NadirParser.unaryOperator_return unaryOperator188 = default(NadirParser.unaryOperator_return);

        NadirParser.castExpression_return castExpression189 = default(NadirParser.castExpression_return);


        NadirAST loc_tree=null;
        RewriteRuleTokenStream stream_220 = new RewriteRuleTokenStream(adaptor,"token 220");
        RewriteRuleTokenStream stream_219 = new RewriteRuleTokenStream(adaptor,"token 219");
        RewriteRuleSubtreeStream stream_unaryOperator = new RewriteRuleSubtreeStream(adaptor,"rule unaryOperator");
        RewriteRuleSubtreeStream stream_castExpression = new RewriteRuleSubtreeStream(adaptor,"rule castExpression");
        try 
    	{
            // C:\\nadir\\nadir\\Nadir\\Parsing\\Nadir.g:500:9: ( postfixExpression | loc= '++' castExpression -> ^( PrePlusPlus[$loc] castExpression ) | loc= '--' castExpression -> ^( PreMinusMinus[$loc] castExpression ) | unaryOperator castExpression -> ^( unaryOperator castExpression ) )
            int alt62 = 4;
            switch ( input.LA(1) ) 
            {
            case ID:
            case INT:
            case FLOAT:
            case STRING:
            case BOOL:
            case SEQDESIGN:
            case 159:
            case 185:
            case 225:
            case 227:
            case 228:
            case 229:
            case 232:
            	{
                alt62 = 1;
                }
                break;
            case 219:
            	{
                alt62 = 2;
                }
                break;
            case 220:
            	{
                alt62 = 3;
                }
                break;
            case 212:
            case 213:
            case 221:
            case 222:
            	{
                alt62 = 4;
                }
                break;
            	default:
            	    if ( state.backtracking > 0 ) {state.failed = true; return retval;}
            	    NoViableAltException nvae_d62s0 =
            	        new NoViableAltException("", 62, 0, input);

            	    throw nvae_d62s0;
            }

            switch (alt62) 
            {
                case 1 :
                    // C:\\nadir\\nadir\\Nadir\\Parsing\\Nadir.g:500:14: postfixExpression
                    {
                    	root_0 = (NadirAST)adaptor.GetNilNode();

                    	PushFollow(FOLLOW_postfixExpression_in_unaryExpression9770);
                    	postfixExpression185 = postfixExpression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	if ( state.backtracking == 0 ) adaptor.AddChild(root_0, postfixExpression185.Tree);

                    }
                    break;
                case 2 :
                    // C:\\nadir\\nadir\\Nadir\\Parsing\\Nadir.g:501:14: loc= '++' castExpression
                    {
                    	loc=(NadirToken)Match(input,219,FOLLOW_219_in_unaryExpression9787); if (state.failed) return retval; 
                    	if ( (state.backtracking==0) ) stream_219.Add(loc);

                    	PushFollow(FOLLOW_castExpression_in_unaryExpression9789);
                    	castExpression186 = castExpression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	if ( (state.backtracking==0) ) stream_castExpression.Add(castExpression186.Tree);


                    	// AST REWRITE
                    	// elements:          castExpression
                    	// 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();
                    	// 501:49: -> ^( PrePlusPlus[$loc] castExpression )
                    	{
                    	    // C:\\nadir\\nadir\\Nadir\\Parsing\\Nadir.g:501:52: ^( PrePlusPlus[$loc] castExpression )
                    	    {
                    	    NadirAST root_1 = (NadirAST)adaptor.GetNilNode();
                    	    root_1 = (NadirAST)adaptor.BecomeRoot((NadirAST)adaptor.Create(PrePlusPlus, 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 3 :
                    // C:\\nadir\\nadir\\Nadir\\Parsing\\Nadir.g:502:14: loc= '--' castExpression
                    {
                    	loc=(NadirToken)Match(input,220,FOLLOW_220_in_unaryExpression9826); if (state.failed) return retval; 
                    	if ( (state.backtracking==0) ) stream_220.Add(loc);

                    	PushFollow(FOLLOW_castExpression_in_unaryExpression9828);
                    	castExpression187 = castExpression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	if ( (state.backtracking==0) ) stream_castExpression.Add(castExpression187.Tree);


                    	// AST REWRITE
                    	// elements:          castExpression
                    	// 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();
                    	// 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;
    }
    // $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;
    }
Beispiel #10
0
    // $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:      
                    	// 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:44: -> ^( mediadefinition )
                    	{
                    	    // D:\\development\\Less.Net\\lesscss.g:38:47: ^( mediadefinition )
                    	    {
                    	    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                    	    root_1 = (CommonTree)adaptor.BecomeRoot(stream_mediadefinition.NextNode(), root_1);

                    	    adaptor.AddChild(root_0, root_1);
                    	    }

                    	}

                    	retval.Tree = root_0;retval.Tree = root_0;
                    }
                    break;
                case 3 :
                    // D:\\development\\Less.Net\\lesscss.g:38:68: variable
                    {
                    	PushFollow(FOLLOW_variable_in_lessLine192);
                    	variable10 = variable();
                    	state.followingStackPointer--;

                    	stream_variable.Add(variable10.Tree);


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

                    	    adaptor.AddChild(root_0, root_1);
                    	    }

                    	}

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

            }
            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;
    }