Skip to content

Commit 483f7ed

Browse files
author
Jack Li
committed
Init project submission
0 parents  commit 483f7ed

File tree

12 files changed

+1676
-0
lines changed

12 files changed

+1676
-0
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.DS_Store
2+
.vscode
3+
examples
4+
lib
5+
screenshots
6+
src/err.log
7+
src/program
8+
src/out.c

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Compiler Design Project
2+
### How to Compile the Source Code
3+
- Run the Makefile in the root directory and `./compiler` executable will be built.
4+
5+
### How to Compile the Sample Program
6+
- Run `run.sh` or `./compiler < input.txt > out.c 2> err.log`. This will generate a C program named `out.c` and show any compilation errors in `err.log`.
7+
- Run `gcc -o program out.c` to compiler the generated program.
8+
- Test the generated program by running `./program`.

src/Makefile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/make -f
2+
3+
CC = gcc
4+
# CFLAGS = -Wall -I/Users/jack-li/Documents/spring_2022/compiler_design/project/lib/uthash/include # Path to include library
5+
CFLAGS = -std=c99 -Wall -I/home/012/j/jx/jxl180095/compiler_design/lib/uthash/include # Path to include library
6+
7+
# Flags for the Lex implicit rules
8+
LEX = /usr/bin/flex
9+
LFLAGS =
10+
11+
# Implicit Makefile rule to use YACC for C programs
12+
YACC = /usr/bin/bison
13+
YFLAGS = -dy
14+
15+
EXECFILE = compiler
16+
OBJS = parse.o scan.o gen.code.o
17+
18+
.PRECIOUS: scan.c parse.c
19+
20+
all: $(EXECFILE)
21+
22+
clean:
23+
rm -f $(OBJS) $(EXECFILE) y.tab.h parse.c scan.c *~ \#*
24+
25+
$(EXECFILE): $(OBJS)
26+
$(CC) -o $@ $(OBJS)

0 commit comments

Comments
 (0)