%{ #include "bisonUtils.h" #include extern int yylex(); extern void yyerror(char *s); %} %error-verbose %token '=' %token '.' %token '{' %token '}' %token '(' %token ')' %token ':' %token ';' %token ',' %token KEYWORD %token NUM %token COMPOP %token SYMBOL %token THIS %left '+' '-' %left '*' '/' %type NomCompose %type Arg ArgList FuncCall %type Operand Expr %union { char * stringVal; } %% Programme: | Programme Element {fprintf(stderr, "");} Element: KEYWORD {fprintf(stderr, "", $1); } | COMPOP {fprintf(stderr, "", $1); } | Expr {fprintf(stderr, "", $1); } | '=' {fprintf(stderr, "", $1);} | '{' {fprintf(stderr, "", $1);} | '}' {fprintf(stderr, "", $1);} | ':' {fprintf(stderr, "", $1);} | ';' {fprintf(stderr, "", $1);} | error Expr: Operand { fprintf(stderr, "", $1); $$ = copy($1);} | Expr '+' Operand { $$ = c3($1, $2, $3); } | Expr '-' Operand { $$ = c3($1, $2, $3); } | Expr '*' Operand { $$ = c3($1, $2, $3); } | Expr '/' Operand { $$ = c3($1,$2, $3); } ; Operand: Arg { fprintf(stderr, "", $1); $$ = copy($1); } | FuncCall { fprintf(stderr, "", $1); $$ = copy($1); } ; FuncCall: NomCompose '(' ')' {$$ = c3($1, $2, $3); } | NomCompose '(' ArgList ')' {$$ = c4($1, $2, $3, $4); fprintf(stderr, " = %s", $3);} ArgList: Arg {fprintf(stderr, "", $1); $$ = copy($1); } | ArgList ',' Arg { fprintf(stderr, "", $3); $$ = c3($1, $2, $3); } Arg: NUM {$$ = copy($1); } | NomCompose {fprintf(stderr, "", $1); $$ = copy($1);} NomCompose: SYMBOL {fprintf(stderr, "", $1); $$ = copy($1); } | THIS {fprintf(stderr, "", $1); $$ = copy($1); } | NomCompose '.' SYMBOL {fprintf(stderr, "", $3); $$ = c3($1,$2,$3); } %%