Rev 195 | Rev 358 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 195 | Rev 198 | ||
---|---|---|---|
Line 50... | Line 50... | ||
50 | 50 | ||
51 | int pushflag(int x){ |
51 | int pushflag(int x){ |
52 | if(arglistptr < (PARENSTACK-1)) |
52 | if(arglistptr < (PARENSTACK-1)) |
53 | inarglist[++arglistptr] = x; |
53 | inarglist[++arglistptr] = x; |
54 | else{ |
54 | else{ |
55 | yyerror("too many nested parentheses or function calls"); |
55 | yyerror(_strdup("too many nested parentheses or function calls")); |
56 | return true; |
56 | return true; |
57 | } |
57 | } |
58 | return false; |
58 | return false; |
59 | } |
59 | } |
60 | 60 | ||
Line 142... | Line 142... | ||
142 | | expr ',' expr { $$ = $2; $$->child[0] = $1; $$->child[1] = $3; } |
142 | | expr ',' expr { $$ = $2; $$->child[0] = $1; $$->child[1] = $3; } |
143 | /* unary operators */ |
143 | /* unary operators */ |
144 | | '-' expr %prec NEG { $$ = $1; $$->child[0] = 0; $$->child[1] = $2; } |
144 | | '-' expr %prec NEG { $$ = $1; $$->child[0] = 0; $$->child[1] = $2; } |
145 | | '+' expr %prec NEG { $$ = $2; } |
145 | | '+' expr %prec NEG { $$ = $2; } |
146 | /* error tokens */ |
146 | /* error tokens */ |
147 | | TOK_UNKNOWN { yyerror("unknown name"); YYERROR; } |
147 | | TOK_UNKNOWN { yyerror(_strdup("unknown name")); YYERROR; } |
148 | | TOK_BADCHAR { yyerror("disallowed character"); YYERROR; } |
148 | | TOK_BADCHAR { yyerror(_strdup("disallowed character")); YYERROR; } |
149 | ; |
149 | ; |
150 | 150 | ||
151 | %% |
151 | %% |
152 | 152 | ||
153 | struct node *parseexpr(char *s){ |
153 | // Daniel 06 July 2021: Move these two lines out of the function parseexpr(), otherwise the code won't compile in G++ |
154 | struct yy_buffer_state *yy_scan_string(const char*); // hack. correct prototype is buried in lex output |
154 | struct yy_buffer_state *yy_scan_string(const char*); // hack. correct prototype is buried in lex output |
155 | int yyparse(void); // hack. correct prototype appears just after this code, in yacc output |
155 | int yyparse(void); // hack. correct prototype appears just after this code, in yacc output |
- | 156 | ||
- | 157 | struct node *parseexpr(char *s){ |
|
156 | extern int tokpos,tokstart; |
158 | extern int tokpos,tokstart; |
157 | 159 | ||
158 | tokstart = tokpos = 0; |
160 | tokstart = tokpos = 0; |
159 | 161 | ||
160 | if(s){ |
162 | if(s){ |
Line 167... | Line 169... | ||
167 | if(!yyparse()) |
169 | if(!yyparse()) |
168 | return parsetree; |
170 | return parsetree; |
169 | else /* ensure we don't leak memory, on an unsuccessful parse */ |
171 | else /* ensure we don't leak memory, on an unsuccessful parse */ |
170 | freeallnodes(); |
172 | freeallnodes(); |
171 | }else |
173 | }else |
172 | yyerror("null string???"); |
174 | yyerror(_strdup("null string???")); |
173 | return 0; |
175 | return 0; |
174 | } |
176 | } |
175 | 177 | ||
176 | void yyerror(char *msg){ |
178 | void yyerror(char *msg){ |
177 | errstr = msg; |
179 | errstr = msg; |