Esempio n. 1
0
        private Expresion ParseNull()
        {
            Expresion resultado = new LiteralNull();

            lexer.Aceptar();
            return(resultado);
        }
    // $ANTLR start "literal"
    // JavaScript.g:364:1: literal : ( 'null' | 'true' | 'false' | StringLiteral -> StringLiteral[new JSString(ProcessEscapedString($StringLiteral.Text))] | NumericLiteral -> NumericLiteral[new JSNumber($NumericLiteral.Text.ToJSNumber())] | RegexLiteral );
    public JavaScriptParser.literal_return literal() // throws RecognitionException [1]
    {   
        JavaScriptParser.literal_return retval = new JavaScriptParser.literal_return();
        retval.Start = input.LT(1);

        object root_0 = null;

        IToken string_literal430 = null;
        IToken string_literal431 = null;
        IToken string_literal432 = null;
        IToken StringLiteral433 = null;
        IToken NumericLiteral434 = null;
        IToken RegexLiteral435 = null;

        object string_literal430_tree=null;
        object string_literal431_tree=null;
        object string_literal432_tree=null;
        object StringLiteral433_tree=null;
        object NumericLiteral434_tree=null;
        object RegexLiteral435_tree=null;
        RewriteRuleTokenStream stream_StringLiteral = new RewriteRuleTokenStream(adaptor,"token StringLiteral");
        RewriteRuleTokenStream stream_NumericLiteral = new RewriteRuleTokenStream(adaptor,"token NumericLiteral");

        try 
    	{
            // JavaScript.g:365:2: ( 'null' | 'true' | 'false' | StringLiteral -> StringLiteral[new JSString(ProcessEscapedString($StringLiteral.Text))] | NumericLiteral -> NumericLiteral[new JSNumber($NumericLiteral.Text.ToJSNumber())] | RegexLiteral )
            int alt216 = 6;
            switch ( input.LA(1) ) 
            {
            case 112:
            	{
                alt216 = 1;
                }
                break;
            case 113:
            	{
                alt216 = 2;
                }
                break;
            case 114:
            	{
                alt216 = 3;
                }
                break;
            case StringLiteral:
            	{
                alt216 = 4;
                }
                break;
            case NumericLiteral:
            	{
                alt216 = 5;
                }
                break;
            case RegexLiteral:
            	{
                alt216 = 6;
                }
                break;
            	default:
            	    if ( state.backtracking > 0 ) {state.failed = true; return retval;}
            	    NoViableAltException nvae_d216s0 =
            	        new NoViableAltException("", 216, 0, input);

            	    throw nvae_d216s0;
            }

            switch (alt216) 
            {
                case 1 :
                    // JavaScript.g:365:4: 'null'
                    {
                    	root_0 = (object)adaptor.GetNilNode();

                    	string_literal430=(IToken)Match(input,112,FOLLOW_112_in_literal3258); if (state.failed) return retval;
                    	if ( state.backtracking == 0 )
                    	{string_literal430_tree = new LiteralNull(string_literal430) ;
                    		adaptor.AddChild(root_0, string_literal430_tree);
                    	}

                    }
                    break;
                case 2 :
                    // JavaScript.g:366:4: 'true'
                    {
                    	root_0 = (object)adaptor.GetNilNode();

                    	string_literal431=(IToken)Match(input,113,FOLLOW_113_in_literal3266); if (state.failed) return retval;
                    	if ( state.backtracking == 0 )
                    	{string_literal431_tree = new LiteralTrue(string_literal431) ;
                    		adaptor.AddChild(root_0, string_literal431_tree);
                    	}

                    }
                    break;
                case 3 :
                    // JavaScript.g:367:4: 'false'
                    {
                    	root_0 = (object)adaptor.GetNilNode();

                    	string_literal432=(IToken)Match(input,114,FOLLOW_114_in_literal3274); if (state.failed) return retval;
                    	if ( state.backtracking == 0 )
                    	{string_literal432_tree = new LiteralFalse(string_literal432) ;
                    		adaptor.AddChild(root_0, string_literal432_tree);
                    	}

                    }
                    break;
                case 4 :
                    // JavaScript.g:368:4: StringLiteral
                    {
                    	StringLiteral433=(IToken)Match(input,StringLiteral,FOLLOW_StringLiteral_in_literal3282); if (state.failed) return retval; 
                    	if ( (state.backtracking==0) ) stream_StringLiteral.Add(StringLiteral433);



                    	// AST REWRITE
                    	// elements:          StringLiteral
                    	// 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.GetNilNode();
                    	// 368:18: -> StringLiteral[new JSString(ProcessEscapedString($StringLiteral.Text))]
                    	{
                    	    adaptor.AddChild(root_0, new LiteralNode(StringLiteral, new JSString(ProcessEscapedString(StringLiteral433.Text))));

                    	}

                    	retval.Tree = root_0;retval.Tree = root_0;}
                    }
                    break;
                case 5 :
                    // JavaScript.g:369:4: NumericLiteral
                    {
                    	NumericLiteral434=(IToken)Match(input,NumericLiteral,FOLLOW_NumericLiteral_in_literal3295); if (state.failed) return retval; 
                    	if ( (state.backtracking==0) ) stream_NumericLiteral.Add(NumericLiteral434);



                    	// AST REWRITE
                    	// elements:          NumericLiteral
                    	// 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.GetNilNode();
                    	// 369:19: -> NumericLiteral[new JSNumber($NumericLiteral.Text.ToJSNumber())]
                    	{
                    	    adaptor.AddChild(root_0, new LiteralNode(NumericLiteral, new JSNumber(NumericLiteral434.Text.ToJSNumber())));

                    	}

                    	retval.Tree = root_0;retval.Tree = root_0;}
                    }
                    break;
                case 6 :
                    // JavaScript.g:370:4: RegexLiteral
                    {
                    	root_0 = (object)adaptor.GetNilNode();

                    	RegexLiteral435=(IToken)Match(input,RegexLiteral,FOLLOW_RegexLiteral_in_literal3308); if (state.failed) return retval;
                    	if ( state.backtracking == 0 )
                    	{RegexLiteral435_tree = new LiteralRegex(RegexLiteral435) ;
                    		adaptor.AddChild(root_0, RegexLiteral435_tree);
                    	}

                    }
                    break;

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

            if ( (state.backtracking==0) )
            {	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;
    }
Esempio n. 3
0
 public virtual void Visit(LiteralNull node)
 {
 }
Esempio n. 4
0
 public void Visit(LiteralNull node)
 {
 }