#define YYSTYPE int
static YYSTYPE exprMerge (YYSTYPE x0, YYSTYPE x1);
int yylex (void);
-int yyerror (char const *msg);
+void yyerror (char const *msg);
%}
return yyparse ();
}
-int
+void
yyerror (char const *msg)
{
fprintf (stderr, "%s\n", msg);
- exit (4);
}
{ $$ = $1; }
| var ',' var_list
{
- $$ = malloc (strlen ($1) + 1 + strlen ($3) + 1);
- strcpy ($$, $1);
- strcat ($$, ",");
- strcat ($$, $3);
+ char *s = (char *) malloc (strlen ($1) + 1 + strlen ($3) + 1);
+ strcpy (s, $1);
+ strcat (s, ",");
+ strcat (s, $3);
+ $$ = s;
}
;
yylex (void)
{
char buf[50];
+ char *s;
switch (fscanf (yyin, " %1[a-z,]", buf)) {
case 1:
return buf[0];
break;
}
if (fscanf (yyin, "%49s", buf) != 1)
- abort ();
+ return 0;
if (sizeof buf - 1 <= strlen (buf))
abort ();
- yylval = malloc (strlen (buf) + 1);
- strcpy (yylval, buf);
+ s = (char *) malloc (strlen (buf) + 1);
+ strcpy (s, buf);
+ yylval = s;
return 'V';
}
main (int argc, char **argv)
{
yyin = stdin;
- if (argc == 2 && !(yyin = fopen (argv[1], "r"))) return 1;
+ if (argc == 2 && !(yyin = fopen (argv[1], "r"))) return 3;
return yyparse ();
}
]])
static int MergeRule (int x0, int x1);
static void yyerror(char const * s);
+int yylex (void);
#define RULE(x) (1 << (x))
char inp[3];
if (fscanf (yyin, "%2s", inp) == EOF)
return 0;
- switch (inp[0])
+ switch (inp[0])
{
case 'p': return P[inp[1] - '1'];
case 't': return T[inp[1] - '1'];
int main(int argc, char* argv[]) {
yyin = stdin;
- if (argc == 2 && !(yyin = fopen (argv[1], "r"))) return 1;
+ if (argc == 2 && !(yyin = fopen (argv[1], "r"))) return 3;
return yyparse ();
}
]])