2 * Code generation using subroutine arguments
4 * Copyright (C) 2018 Nicolas Mauger
5 * This file is subject to the terms and conditions of the
6 * CeCILL free software license agreement. See the file
7 * LICENSE in the main directory of T7 for more details.
14 void expression (char *tempvar ) ;
15 void factor (char *tempvar ) ;
16 void term (char *tempvar ) ;
18 extern char *newname (void ) ;
19 extern void freename (char *name);
21 void statements(char *tempvar)
23 /* statements -> expression SEMI | expression SEMI statements */
27 expression(tempvar = newname());
30 if (match(SEMI)) advance();
33 fprintf(stderr, "%d: Inserting missing semicolon\n", yylineno);
38 void expression(char *tempvar)
40 /* expression -> term expression'
41 * expression' -> PLUS term expression' | epsilon
51 term(tempvar2 = newname());
53 printf(" %s += %s\n", tempvar, tempvar2);
58 void term(char *tempvar)
68 factor(tempvar2 = newname());
69 printf(" %s *= %s\n", tempvar, tempvar2);
74 void factor(char *tempvar)
78 printf(" %s = %-*s\n", tempvar, yyleng, yytext);
86 if (match(RP)) advance();
89 fprintf(stderr, "%d: Mismatched parenthesis\n", yylineno);
94 fprintf(stderr, "%d: Number or identifier expected\n", yylineno);