/* file name : list2.y */ /* right recursive production demonstration */ %{ #define YYSTYPE double %} %token NUMBER %% input : list '\n' | input list ; list : NUMBER ',' list { printf ("\t= %.2f\n", $1); } | NUMBER { printf ("\t= %.2f\n", $1); } ; %% main () { yyparse (); } yyerror (char *s) /* Called by yyparse on error */ { printf ("\terror: %s\n", s); }