ref: f3b75c3f5712d0be6e769da93e97fb0c1ae77143
parent: 221a1f2cdc59935197d4bd14669e78bec521c0aa
author: Ori Bernstein <[email protected]>
date: Tue Jan 10 04:15:55 EST 2012
Move main file to backend.
--- /dev/null
+++ b/8/Makefile
@@ -1,0 +1,9 @@
+BIN=8m
+OBJ=main.o
+
+CFLAGS+=-I../parse
+LDFLAGS+=-L../parse -lparse
+
+include ../mk/lexyacc.mk
+include ../mk/c.mk
+
--- /dev/null
+++ b/8/main.c
@@ -1,0 +1,83 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <ctype.h>
+#include <string.h>
+#include <assert.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include "parse.h"
+
+Node *file;
+static char *outfile;
+int debug;
+
+static void usage(char *prog)
+{
+ printf("%s [-h] [-o outfile] inputs\n", prog);
+ printf("\t-h\tPrint this help\n");
+ printf("\t-o\tOutput to outfile\n");
+}
+
+int main(int argc, char **argv)
+{
+ int opt;
+ int i;
+ Node *rdback;
+ FILE *tmp;
+
+ while ((opt = getopt(argc, argv, "dho:")) != -1) {
+ switch (opt) {
+ case 'o':
+ outfile = optarg;
+ break;
+ case 'h':
+ case 'd':
+ debug++;
+ break;
+ default:
+ usage(argv[0]);
+ exit(0);
+ break;
+ }
+ }
+
+ for (i = optind; i < argc; i++) {
+ tyinit();
+ tokinit(argv[i]);
+ file = mkfile(argv[i]);
+ file->file.exports = mkstab();
+ file->file.globls = mkstab();
+ yyparse();
+
+ /* before we do anything to the parse */
+ dump(file, stdout);
+
+ infer(file);
+
+ /* test storing tree to file */
+ tmp = fopen("test.pkl", "w");
+ pickle(file, tmp);
+ fclose(tmp);
+
+ /* and reading it back */
+ tmp = fopen("test.pkl", "r");
+ rdback = unpickle(tmp);
+ dump(rdback, stdout);
+ fclose(tmp);
+
+ /* after all processing */
+ dump(file, stdout);
+ gen();
+ }
+
+ return 0;
+}
+
+void gen(void)
+{
+ printf("GEN!\n");
+}
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,5 @@
-SUB = parse
+SUB = parse \
+ 8
-include config.mk
include mk/c.mk
--- a/parse/Makefile
+++ b/parse/Makefile
@@ -1,10 +1,9 @@
-BIN=pt
+LIB=libparse.a
OBJ=bitset.o \
dump.o \
gram.o \
htab.o \
infer.o \
- main.o \
names.o \
node.o \
pickle.o \
@@ -18,6 +17,3 @@
include ../mk/lexyacc.mk
include ../mk/c.mk
-
-ops.o: ../mc/ops.c
- $(CC) -c $(CFLAGS) $<
--- a/parse/main.c
+++ /dev/null
@@ -1,83 +1,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <ctype.h>
-#include <string.h>
-#include <assert.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-
-#include "parse.h"
-
-Node *file;
-static char *outfile;
-int debug;
-
-static void usage(char *prog)
-{
- printf("%s [-h] [-o outfile] inputs\n", prog);
- printf("\t-h\tPrint this help\n");
- printf("\t-o\tOutput to outfile\n");
-}
-
-int main(int argc, char **argv)
-{
- int opt;
- int i;
- Node *rdback;
- FILE *tmp;
-
- while ((opt = getopt(argc, argv, "dho:")) != -1) {
- switch (opt) {
- case 'o':
- outfile = optarg;
- break;
- case 'h':
- case 'd':
- debug++;
- break;
- default:
- usage(argv[0]);
- exit(0);
- break;
- }
- }
-
- for (i = optind; i < argc; i++) {
- tyinit();
- tokinit(argv[i]);
- file = mkfile(argv[i]);
- file->file.exports = mkstab();
- file->file.globls = mkstab();
- yyparse();
-
- /* before we do anything to the parse */
- dump(file, stdout);
-
- infer(file);
-
- /* test storing tree to file */
- tmp = fopen("test.pkl", "w");
- pickle(file, tmp);
- fclose(tmp);
-
- /* and reading it back */
- tmp = fopen("test.pkl", "r");
- rdback = unpickle(tmp);
- dump(rdback, stdout);
- fclose(tmp);
-
- /* after all processing */
- dump(file, stdout);
- gen();
- }
-
- return 0;
-}
-
-void gen(void)
-{
- printf("GEN!\n");
-}