%{ extern int yylex(); #include #include #include #include "proto-color.h" int yyerror (char const *message) { fprintf(stderr,RED("<%s>")"\n", message); return 0; } #include "langnat1.c" struct sPhrase laPhrase; struct sGNom * sgn; %} %union { char * string; void * structure; } %token ART NOM VERBE ADJ %token '\n' %type Phrase GpeNom %% Texte : | Texte Phrase '\n' ; Phrase : GpeNom VERBE GpeNom { enregistrerPhrase( &laPhrase, $1, $2, $3 ); listePhrase( &laPhrase ); } ; GpeNom : ART ADJ NOM { sgn = creerGNom($1,$3,$2); printf(" ",$1,$2,$3); $$ = sgn; } | ART NOM ADJ { sgn = creerGNom($1,$2,$3); printf(" ",$1,$2,$3); $$ = sgn; } | ART NOM { sgn = creerGNom($1,$2,0); printf(" ",$1,$2); $$ = sgn; } ; %% int main(void) { return yyparse(); }