diff --git a/Makefile b/Makefile index 2bbf4a9..6403429 100644 --- a/Makefile +++ b/Makefile @@ -6,5 +6,8 @@ scan: main.cpp scanner.cpp scanner.cpp: scanner.l flex -o scanner.cpp scanner.l +parser.tab.cpp: parser.y + bison -d parser.y + clean: rm -f scan scanner.cpp diff --git a/parser.y b/parser.y new file mode 100644 index 0000000..4f7dbc0 --- /dev/null +++ b/parser.y @@ -0,0 +1,58 @@ +%{ + +#include + +%} + +%token INDENT +%token DEDENT +%token NEWLINE +%token AND +%token BREAK +%token DEF +%token ELIF +%token ELSE +%token FOR +%token IF +%token NOT +%token OR +%token RETURN +%token WHILE +%token BOOLEAN +%token IDENTIFIER +%token ASSIGN +%token PLUS +%token MINUS +%token TIMES +%token DIVIDEDBY +%token EQ +%token NEQ +%token GT +%token GTE +%token LT +%token LTE +%token LPAREN +%token RPAREN +%token COMMA +%token COLON + +%define api.value.type { std::string } +%define api.pure full +%define api.push-pull push + +%% + +program + : statements {} + ; + +statements + : statement statements {} + | statement {} + ; + +statement + : PLUS {} + ; + +%%