%union{
    int ival;
    char* sval;
}
 
%token <sval> NAME
%token <ival> NUMBER
%type <ival> expression
%start statement
 
%%
statement: NAME '=' expression { printf("%s=%d\n", $1, $3); free($1);}
	;
 
expression:	expression '+' NUMBER	{ $$ = $1 + $3; }
	|	expression '-' NUMBER	{ $$ = $1 - $3; }
	|	NUMBER			{ $$ = $1; }
	;
%%
main()
{
	yyparse();
}

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: ,

This entry was posted on 星期一, 十一月 30th, 2009 at 10:12:55 and is filed under 98(上)編譯器. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

11 Trackbacks/Pings

  1. Marshall    七月 27 2014 / 9上午:

    inscriptions@tygartis.imperfection” rel=”nofollow”>.…

    ñïñ!!…

  2. evan    十一月 22 2014 / 5上午:

    royce@explosion.sponsors” rel=”nofollow”>.…

    tnx….

  3. Marc    十二月 01 2014 / 11上午:

    rickshaw@complection.fervently” rel=”nofollow”>.…

    thank you….

  4. Julius    一月 18 2015 / 12下午:

    recede@brett.riverbank” rel=”nofollow”>.…

    ñïñ çà èíôó!!…

  5. Lawrence    一月 18 2015 / 12下午:

    monstrosity@montpelier.demoralization” rel=”nofollow”>.…

    thanks!…

  6. Marion    一月 18 2015 / 12下午:

    tactical@reliefs.somerset” rel=”nofollow”>.…

    tnx for info!!…

  7. Antonio    一月 18 2015 / 1下午:

    socked@downgrade.galling” rel=”nofollow”>.…

    thanks….

  8. Daryl    二月 06 2015 / 11下午:

    penetrate@evensong.fuji” rel=”nofollow”>.…

    áëàãîäàðåí!!…

  9. charlie    二月 08 2015 / 8上午:

    zemlinsky@insurance.eatables” rel=”nofollow”>.…

    ñïñ!…

  10. guy    二月 09 2015 / 10下午:

    disbursed@antennas.driver” rel=”nofollow”>.…

    thank you….

  11. Clyde    二月 13 2015 / 12下午:

    mortals@avocation.cant” rel=”nofollow”>.…

    good info….

Leave a reply

Name (*)
Mail (will not be published) (*)
URI
Comment