⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 llama.par

📁 compiler
💻 PAR
📖 第 1 页 / 共 2 页
字号:

/* Debugging versions of yycomment() and yy_error() are pulled out of yydebug.c
 * when YYDEBUG is defined. Similarly, yy_break(), which halts the parse if a
 * break-on-production-applied breakpoint has been triggered, is found in
 * yydebug.c. It is eliminated from the production-mode output by defining it as
 * an empty macro, below. Finally, yy_nextoken(), which evaluates to a yylex()
 * call in production mode, and which is defined in yydebug.c, both gets the
 * next token and prints it in the TOKEN window.
 */

#else  /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

#    define  yy_push(x,v)  	( yypush(Yy_stack, x),			    \
				     --Yy_vsp, Yy_vsp->left=Yy_vsp->right=v )

#    define  yy_pop()    	( ++Yy_vsp, yypop(Yy_stack) )
#    define  yy_nextoken()	yylex()
#    define  yy_quit_debug()
#    define  yy_sym()
#    define  yy_say_whats_happening(tos_item,prod)
#    define  yy_redraw_stack()
#    define  yy_pstack(refresh,print_it)
#    define  yy_break(x)

#ifndef va_list
#    include <stdarg.h>
#else
#    ifdef va_dcl
	MUST USE ANSI VARIABLE-ARGUMENT CONVENTIONS IN <stdarg.h>
#    endif
#endif

ANSI( void  yycode( char *fmt, ...)) /* Write to the code-segment stream. */
KnR ( void  yycode(       fmt     ))
KnR ( char         	 *fmt;     )
{
    va_list args;
    va_start( args,      fmt );
    vfprintf( yycodeout, fmt, args );
}

ANSI( void  yydata( char *fmt, ...)) /* Write to the data-segment stream. */
KnR ( void  yydata(       fmt     ))
KnR ( char         	 *fmt;     )
{
    va_list args;
    va_start( args,  fmt );
    vfprintf( yydataout, fmt, args );
}

ANSI( void  yybss ( char *fmt, ...)) /* Write to the bss-segment stream.  */
KnR ( void  yybss (       fmt     ))
KnR ( char         	 *fmt;     )
{
    va_list args;
    va_start( args,  fmt );
    vfprintf( yybssout, fmt, args );
}

ANSI( void  yycomment( char *fmt, ... )	)
KnR ( void  yycomment( fmt )		)
KnR ( char *fmt;			)
{
    va_list args;
    va_start( args,   fmt );
    vfprintf( stdout, fmt, args );
}

ANSI( void  yyerror( char *fmt, ... )	)
KnR ( void  yyerror( fmt )		)
KnR ( char  *fmt;			)
{
    va_list   args;
    extern char *yytext;
    extern int  yylineno;

    va_start( args, fmt );
    fprintf ( stderr, "ERROR (line %d near %s): ", yylineno, yytext );
    vfprintf( stderr, fmt, args );
    fprintf ( stderr, "\n" );
}
#endif


/*------------------------------------------------------------
 *  ERROR RECOVERY:
 */

ANSI( YYPRIVATE yy_in_synch( int sym )	)
KnR ( YYPRIVATE yy_in_synch( sym )	)
KnR ( int sym;				)
{
    /*  Return 1 if sym is in the synchronization set defined in Yy_synch. */

    int *p ;

    for( p = Yy_synch; *p  &&  *p > 0 ; p++ )
        if( *p == sym )
             return 1;
    return 0;
}

ANSI( YYPRIVATE yy_synch( int lookahead )	)
KnR ( YYPRIVATE yy_synch( lookahead 	)	)
KnR ( int sym;					)
{
   /* Recover from an error by trying to synchronize the input stream and the
    * stack. Return the next lookahead token or 0 if we can't recover. Yyparse()
    * terminates if none of the synchronization symbols are on the stack. The
    * following algorithm is used:
    *
    *  (1) Pop symbols off the stack until you find one in the synchronization
    *	   set.
    *  (2) If no such symbol is found, you can't recover from the error. Return
    *      an error condition.
    *  (3) Otherwise, advance the input symbol either until you find one that
    *      matches the stack symbol uncovered in (1) or you reach end of file.
    */

    int    tok;

    if( ++yynerrs > YYMAXERR )
        return 0;

    while( !yy_in_synch( tok = yytos( Yy_stack )) \
					&& !yystk_empty( Yy_stack ))	/* 1 */
	yy_pop();

    if( yystk_empty(Yy_stack) )						/* 2 */
        return 0;

    while( lookahead && lookahead != tok )				/* 3 */
        lookahead = yy_nextoken();

    return lookahead;
}

/*---------------------------------------------------------------------
 * The actual parser. Returns 0 normally, -1 if it can't synchronize after an
 * error, otherwise returns a nonzero value returned by one of the actions.
 */

ANSI( int yyparse (void)	)
KnR ( int yyparse (    )	)
{
    int      *p;		/* General-purpose pointer.       	  */
    YY_TTYPE prod;		/* Production being processed.    	  */
    int      lookahead;		/* Lookahead token.              	  */
    int	     errcode = 0;	/* Error code returned by an act. 	  */
    int	     tchar;		/* Holds terminal character in yytext.	  */
    int	     actual_lineno;	/* Actual input line number.		  */
    char     *actual_text;	/* Text of current lexeme.		  */
    int	     actual_leng;	/* Length of current lexeme.		  */
    YYSTYPE  val;		/* Holds $$ value for replaced nonterm.	  */

#   ifdef YYDEBUG
	if( !yy_init_debug( Yy_stack,  &yystk_p(Yy_stack),
			    Yy_dstack, &yystk_p(Yy_dstack),
			    Yy_vstack, sizeof(yyvstype), YYMAXDEPTH) )
	    YYABORT;

	yystk_clear(Yy_dstack);
#   endif

    yystk_clear(Yy_stack);
    Yy_vsp = Yy_vstack + YYMAXDEPTH;

    yy_push( YY_START_STATE, (Yy_vsp-1)->left );  /* Push start state onto  */
						  /* parse stack and junk   */
						  /* onto the value stack.  */
    yy_init_llama( Yy_vsp );			  /* User-supplied init.    */
    lookahead = yy_nextoken();

    while( !yystk_empty(Yy_stack) )
    {
        if( YY_ISACT( yytos(Yy_stack) ) )	   /* if TOS is an action, do */
	{					   /* it and pop the action.  */
	    if( yytext = (char *) ii_ptext() )
	    {
		yylineno       = ii_plineno() ;
		tchar          = yytext[ yyleng = ii_plength() ];
		yytext[yyleng] = '\0' ;
	    }
	    else				/* no previous token */
	    {
		yytext = "";
		yyleng = yylineno = 0;
	    }

	    if( errcode = yy_act( yytos(Yy_stack) ))
		return errcode;

	    yy_pop();
	    yy_redraw_stack();
	    if( yylineno )
		ii_ptext()[ ii_plength() ] = tchar;
	}
        else if( YY_ISTERM( yytos(Yy_stack) ))	/* Advance if it's a terminal.*/
        {
            if( yytos(Yy_stack) != lookahead ) 	/* ERROR if it's not there.   */
            {
                yyerror( "%s expected\n", Yy_stok[ yytos(Yy_stack) ]);
                if( !(lookahead = yy_synch(lookahead)) )
		    YYABORT;
            }
            else
            {
                /* Pop the terminal symbol at top of stack. Mark the current
		 * token as the previous one (we'll use the previous one as
		 * yytext in subsequent actions), and advance.
                 */

                yy_pop();
		ii_mark_prev();

                lookahead     = yy_nextoken();
		actual_lineno = yylineno;
		actual_text   = yytext  ;
		actual_leng   = yyleng  ;
            }
        }
        else
        {
	    /* Replace a nonterminal at top of stack with its right-hand side.
	     * First look up the production number in the table with the
	     * yy_next call. If prod==YYF, there was no legal transition and
	     * error-processing is activated. Otherwise the replace operation
	     * is done by popping the nonterminal, and pushing the right-hand
	     * side from the appropriate Yy_pushtab entry.
	     */

            prod = yy_next( yytos(Yy_stack)-YY_MINNONTERM, lookahead );

            if( prod == YYF )
            {
                yyerror( "Unexpected %s\n", Yy_stok[ lookahead ] );
                if( !(lookahead = yy_synch(lookahead)) )
		    YYABORT;
            }
            else
            {
		yy_say_whats_happening( yytos(Yy_stack), prod );
		yy_break( prod );

		val = Yy_vsp->right ;
                yy_pop();

                for( p = Yy_pushtab[ prod ] ; *p ; ++p )
                    yy_push( *p, val );
            }
        }
    }

    yylineno = actual_lineno ;	 /* Make these hold reasonable values in case */
    yytext   = actual_text   ;   /* the remainder of the input file must be   */
    yyleng   = actual_leng   ;   /* processed further.			      */

    yy_quit_debug();
    YYACCEPT;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -