45 lines
1.3 KiB
Text
45 lines
1.3 KiB
Text
$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);}
|