aboutsummaryrefslogtreecommitdiff
path: root/gramar.y
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2012-04-17 18:23:52 +0000
committerDimitri Sokolyuk <demon@dim13.org>2012-04-17 18:23:52 +0000
commit245459ae8c15554418d6d54ba0ab220b9eba0620 (patch)
tree355ad9c0566dfab3ecca102537806cd15b07efde /gramar.y
parent20e9a95075a7a95df90daa7c9bb4af0dff8ebf0d (diff)
cleanup, make it build on linux (freebsd-make)
Diffstat (limited to 'gramar.y')
-rw-r--r--gramar.y18
1 files changed, 14 insertions, 4 deletions
diff --git a/gramar.y b/gramar.y
index 61fdd1a..806917d 100644
--- a/gramar.y
+++ b/gramar.y
@@ -18,13 +18,18 @@
%{
#include <sys/queue.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
-#include "dcpu16.h"
extern int yylineno;
extern FILE *yyin;
int yylex(void);
int yyparse(void);
+void yyerror(const char *);
+void push(int, char *);
+void popop(int);
+void popall(void);
+void addref(char *);
#if YYDEBUG
extern int yydebug;
@@ -39,8 +44,8 @@ int sp = 0;
int rp = 0;
int pc = 0;
-unsigned short buffer[MEMSZ];
-char *label[MEMSZ];
+unsigned short *buffer;
+char **label;
%}
@@ -267,14 +272,19 @@ restorerefs(void)
}
unsigned short *
-compile(FILE *fd)
+compile(FILE *fd, size_t sz)
{
+ buffer = calloc(sz, sizeof(unsigned short));
+ label = calloc(sz, sizeof(char *));
+
#if YYDEBUG
yydebug = 1;
#endif
+
yyin = fd;
yyparse();
restorerefs();
+ free(label);
return buffer;
}