/* $Id: glue.y,v 1.4 2004/01/15 20:10:41 jmuelmen Exp $ */ %{ #include #include #include #include "glue.h" extern char *yytext; int yylex (); void yyerror (const char *s); void glue_gen (); %} %token IDENTIFIER DOUBLE INT CHAR VOID CONST %start declaration_list %% identifier : IDENTIFIER { strncpy(i->name, yytext, IDENT_LEN); } ; type_spec : DOUBLE { $$ = double_t; } | INT { $$ = int_t; } | CHAR '*' { $$ = string_t; } | VOID { $$ = void_t; } ; modifier : CONST | ; argument : modifier type_spec { $$ = $2; } | modifier type_spec IDENTIFIER { $$ = $2; } ; argument_list : argument { i->argt[i->argc++] = $1; } | argument_list ',' argument { i->argt[i->argc++] = $3; } ; declaration : type_spec identifier '(' ')' ';' { i->ret = $1; i->argc = 0; glue_gen(glue_file, glue_header_file, register_file); } | type_spec identifier '(' { i->ret = $1; i->argc = 0; } argument_list ')' ';' { glue_gen(glue_file, glue_header_file, register_file); } ; declaration_list : /* empty */ | declaration declaration_list ; %% void yyerror (const char *s) { printf("%s\n", s); exit(1); }