Merge branch 'Dev' into Sprint2-SymbolTableOperations-FE-t#29
I need to make sure that all the changes in dev will work with all the changes in Sprint2-SymbolTableOperations-FE-t#29
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@ -2,3 +2,5 @@
|
|||||||
*.o
|
*.o
|
||||||
alpha
|
alpha
|
||||||
flex.h
|
flex.h
|
||||||
|
grammar.tab.c
|
||||||
|
grammar.tab.h
|
14
Makefile
14
Makefile
@ -2,10 +2,9 @@ CC := gcc
|
|||||||
FLEX := flex
|
FLEX := flex
|
||||||
LEX := lexicalStructure.lex
|
LEX := lexicalStructure.lex
|
||||||
EXE := alpha
|
EXE := alpha
|
||||||
CFLAGS := -std=c99 -Wall
|
CFLAGS :=
|
||||||
CPPFLAGS :=
|
|
||||||
|
|
||||||
build: lex.yy.c runner.o runner
|
compiler: lex.yy.c runner.o runner
|
||||||
|
|
||||||
lex.yy.c: lexicalStructure.lex
|
lex.yy.c: lexicalStructure.lex
|
||||||
$(FLEX) -o lex.yy.c $(LEX)
|
$(FLEX) -o lex.yy.c $(LEX)
|
||||||
@ -14,10 +13,13 @@ runner.o: runner.c runner.h flex.h
|
|||||||
$(CC) $(CFLAGS) -o runner.o -c runner.c
|
$(CC) $(CFLAGS) -o runner.o -c runner.c
|
||||||
|
|
||||||
runner: lex.yy.c runner.o
|
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: CFLAGS += -DDEBUG=1
|
||||||
debug: clean runner
|
debug: clean compiler
|
||||||
|
|
||||||
test:
|
test:
|
||||||
./$(EXE) ./tests/test_comments.alpha
|
./$(EXE) ./tests/test_comments.alpha
|
||||||
@ -48,4 +50,6 @@ clean:
|
|||||||
rm -f $(EXE)
|
rm -f $(EXE)
|
||||||
rm -f flex.h
|
rm -f flex.h
|
||||||
rm -f *.tok
|
rm -f *.tok
|
||||||
|
rm -f grammar.tab.c
|
||||||
|
rm -f grammar.tab.h
|
||||||
rm -f *.st
|
rm -f *.st
|
@ -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
|
|
17
README.MD
Normal file
17
README.MD
Normal file
@ -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.*
|
11
grammar.y
11
grammar.y
@ -1,3 +1,11 @@
|
|||||||
|
/* Syntax Analyzer with Bison (3.8.1) */
|
||||||
|
/* (referenced Bison manual for file boilerplate [3.1]) */
|
||||||
|
|
||||||
|
// Prologue
|
||||||
|
%{
|
||||||
|
#include <stdio.h>
|
||||||
|
%}
|
||||||
|
|
||||||
%token ID 101
|
%token ID 101
|
||||||
%token T_INTEGER 201
|
%token T_INTEGER 201
|
||||||
%token T_ADDRESS 202
|
%token T_ADDRESS 202
|
||||||
@ -44,3 +52,6 @@
|
|||||||
%token RESERVE 613
|
%token RESERVE 613
|
||||||
%token RELEASE 614
|
%token RELEASE 614
|
||||||
%token COMMENT 700
|
%token COMMENT 700
|
||||||
|
%%
|
||||||
|
|
||||||
|
%%
|
||||||
|
@ -81,6 +81,8 @@ SCHAR \\n|\\t|\\\"|[^\"\n\\]
|
|||||||
{ID} {if(DEBUG) {printf( "ID: %s (%d)\n", yytext, ID);} else {return ID;}}
|
{ID} {if(DEBUG) {printf( "ID: %s (%d)\n", yytext, ID);} else {return ID;}}
|
||||||
|
|
||||||
\n {line_number++; column_number = 1;}
|
\n {line_number++; column_number = 1;}
|
||||||
. {column_number++;}
|
\t {column_number++;}
|
||||||
|
" " {column_number++;}
|
||||||
|
. {column_number++; return 1999;}
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
7
runner.c
7
runner.c
@ -1,4 +1,4 @@
|
|||||||
#include "symbol_table.h"
|
//#include "symbol_table.h"
|
||||||
#include "symbol_table.c"
|
#include "symbol_table.c"
|
||||||
#include "runner.h"
|
#include "runner.h"
|
||||||
|
|
||||||
@ -80,12 +80,15 @@ int run(FILE *alpha) {
|
|||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if(token == 1999){
|
||||||
|
printf("On line number %d and column number %d we have an invalid character:%s\n",line_number,column_number,yytext);
|
||||||
|
}
|
||||||
column_number += yyleng;
|
column_number += yyleng;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (st_flag != NULL) {
|
if (st_flag != NULL) {
|
||||||
//output symbol table, file pointer is
|
//output symbol table, file pointer is
|
||||||
fprintf(st_flag, "just checking that this works \n");
|
print_symbol_table(curr,st_flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (yyin != NULL) {
|
if (yyin != NULL) {
|
||||||
|
4
runner.h
4
runner.h
@ -20,9 +20,9 @@ int arg;
|
|||||||
SymbolTable * top;
|
SymbolTable * top;
|
||||||
SymbolTable * curr;
|
SymbolTable * curr;
|
||||||
|
|
||||||
int main(int argc, char* argv[]);
|
// int main(int argc, char* argv[]);
|
||||||
char *is_tok(int argc, char* argv[]);
|
char *is_tok(int argc, char* argv[]);
|
||||||
int is_alpha_file(char *file, int file_len);
|
// int is_alpha_file(char *file, int file_len);
|
||||||
void enter_scope(int, int);
|
void enter_scope(int, int);
|
||||||
void exit_scope(void);
|
void exit_scope(void);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user