%{ uses YaccLib, LexLib; (* TP4 ex3 *) %} %token ID /* constants */ %type S /* expressions */ %left '+' /* operators */ %left '*' %% input : /* empty */ | input '\n' { yyaccept; } | input S '\n' { writeln($2); } | error '\n' { yyerrok; } S : S '+' S { $$ := $1 + $3; } | S '*' S { $$ := $1 * $3; } | ID { $$ := $1; } %% {$I tp4Lex_3} var i : Integer; begin if yyparse=0 then (* fini! *); end.