From 5171e4bc8649356ce90d3e961a6bae48f2039263 Mon Sep 17 00:00:00 2001 From: Scarlett Date: Thu, 20 Feb 2025 14:30:18 -0500 Subject: [PATCH 1/2] Makefile updated t#30 --- Makefile | 3 ++- Makefile.save | 43 ------------------------------------------- 2 files changed, 2 insertions(+), 44 deletions(-) delete mode 100644 Makefile.save diff --git a/Makefile b/Makefile index 90bdaca..6fb4421 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ EXE := alpha CFLAGS := -std=c99 -Wall CPPFLAGS := -build: lex.yy.c runner.o runner +compiler: lex.yy.c runner.o runner lex.yy.c: lexicalStructure.lex $(FLEX) -o lex.yy.c $(LEX) @@ -38,6 +38,7 @@ test: ./$(EXE) -tok ./tests/test_simpleLiterals.alpha ./$(EXE) -tok ./tests/test_real_alpha_file.alpha ./$(EXE) -tok ./tests/test_real_alpha_2.alpha + clean: rm -f *.o rm -f lex.yy.c diff --git a/Makefile.save b/Makefile.save deleted file mode 100644 index 668af54..0000000 --- a/Makefile.save +++ /dev/null @@ -1,43 +0,0 @@ -CC := gcc -FLEX := flex -LEX := lexicalStructure.lex -EXE := runner -CFLAGS := -std=c99 -Wall -CPPFLAGS := - -runner: flex.o runner.o - $(CC) -o runner runner.o flex.o - -debug: CFLAGS += -DDEBUG=true -debug: clean runner - -runner.o: runner.c runner.h flex.h - $(CC) $(CFLAGS) -o runner.o -c runner.c - -flex.o: lex.yy.c typedefs.h - $(CC) $(CFLAGS) -o flex.o -c lex.yy.c - -lex.yy.c: lexicalStructure.lex - $(FLEX) -o lex.yy.c $(LEX) - -test: - ./$(EXE) ./tests/test_comments.alpha - ./$(EXE) ./tests/test_generalTokenTest.alpha - ./$(EXE) ./tests/test_keywords.alpha - ./$(EXE) ./tests/test_operators.alpha - ./$(EXE) ./tests/test_otherpunc.alpha - ./$(EXE) ./tests/test_simpleIntTest.alpha - ./$(EXE) ./tests/test_simpleLiterals.alpha - ./$(EXE) -tok ./tests/test_comments.alpha - ./$(EXE) -tok ./tests/test_generalTokenTest.alpha - ./$(EXE) -tok ./tests/test_keywords.alpha - ./$(EXE) -tok ./tests/test_operators.alpha - ./$(EXE) -tok ./tests/test_otherpunc.alpha - ./$(EXE) -tok ./tests/test_simpleIntTest.alpha - ./$(EXE) -tok ./tests/test_simpleLiterals.alpha -clean: - rm -f *.o - rm -f lex.yy.c - rm -f $(EXE) - rm -f flex.h - rm -f *.tok From 5505d11d2133ab7eb9779e55eb49e409346c67cb Mon Sep 17 00:00:00 2001 From: Scarlett Date: Fri, 21 Feb 2025 16:18:38 -0500 Subject: [PATCH 2/2] Completed task1 objectives t#30 --- .gitignore | 2 ++ Makefile | 12 ++++++++---- README.MD | 17 +++++++++++++++++ grammar.y | 18 ++++++++++++++++++ 4 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 README.MD create mode 100644 grammar.y diff --git a/.gitignore b/.gitignore index 47f37f6..b927c65 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ *.o alpha flex.h +grammar.tab.c +grammar.tab.h \ No newline at end of file diff --git a/Makefile b/Makefile index 6fb4421..a6d045b 100644 --- a/Makefile +++ b/Makefile @@ -2,8 +2,7 @@ CC := gcc FLEX := flex LEX := lexicalStructure.lex EXE := alpha -CFLAGS := -std=c99 -Wall -CPPFLAGS := +CFLAGS := compiler: lex.yy.c runner.o runner @@ -14,10 +13,13 @@ runner.o: runner.c runner.h flex.h $(CC) $(CFLAGS) -o runner.o -c runner.c runner: lex.yy.c runner.o - $(CC) -o $(EXE) runner.o lex.yy.c + $(CC) $(CFLAGS) -o $(EXE) runner.o lex.yy.c + +bison: grammar.y + bison -d grammar.y debug: CFLAGS += -DDEBUG=1 -debug: clean runner +debug: clean compiler test: ./$(EXE) ./tests/test_comments.alpha @@ -45,3 +47,5 @@ clean: rm -f $(EXE) rm -f flex.h rm -f *.tok + rm -f grammar.tab.c + rm -f grammar.tab.h diff --git a/README.MD b/README.MD new file mode 100644 index 0000000..525582f --- /dev/null +++ b/README.MD @@ -0,0 +1,17 @@ +# The Translators α Compiler +#### Members: Annie Slenker, Meyer Simon, Partho Bhattacharya, & Scarlett Kadan + +## Lexical Analyzer +* **Undefined Behavior:** + * Spaces are not required between tokens. For instance, an INTEGER and an ID are valid even if there is no space between them +``` +Input: *5variable* +Output: 2 14 301 "5" + 1 1 101 "variable" +``` + +## Syntax Analyzer +* *Incomplete* + +## Symbol Table +* *TODO: Create diagram.* \ No newline at end of file diff --git a/grammar.y b/grammar.y new file mode 100644 index 0000000..4a1c8a4 --- /dev/null +++ b/grammar.y @@ -0,0 +1,18 @@ +/* Syntax Analyzer with Bison (3.8.1) */ +/* (referenced Bison manual for file boilerplate [3.1]) */ + +// Prologue +%{ + #include +%} + +// Declarations + + +// Grammar Rules +%% +semicolon.opt: + %empty +| ";" +; +%% \ No newline at end of file