1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
$NetBSD: patch-ag,v 1.3 2015/12/29 23:34:43 dholland Exp $
Use standard headers.
Don't redeclare standard functions.
Fix yacc syntax errors.
--- pascomp/bapascal.y.orig 1999-08-31 18:19:08.000000000 +0200
+++ pascomp/bapascal.y
@@ -3,6 +3,7 @@
/* based on the Pascal grammar from the */
/* primost.cs.wisc.edu compiler archive */
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <time.h>
@@ -25,12 +26,8 @@ extern void global_init(int argc, cha
#include "../include/writetab.h"
#include "../include/pcode.h"
-extern int fprintf(FILE*,const char*,...);
-extern int printf(const char*,...);
-extern int free(void*);
extern void yyerror(char*);
extern int yylex(void);
-extern int atoi(char*);
void process_var_inits(int level);
void add_var_init(int* curr_var, int tix, int level, int value);
@@ -866,7 +863,6 @@ statement : /*empty*/
{ gen_exprval($4); emit1(JZER,$1); free_expr($4); }
| for_header statement
{ emit1(ENDFOR,1+$1); code[$1].y = lc; }
- ;
| cbegin statements CEND
{ if (level == 1) emit(COEND); in_cobegin = 0; }
;
@@ -885,6 +881,7 @@ the_else : ELSE
the_while : WHILE
{ $$ = lc; }
+ ;
while_expr : expr
{ gen_exprval($1); free_expr($1); $$ = lc; emit(JZER);}
|