Add initial parser

This commit is contained in:
Danila Fedorin 2019-05-11 21:19:15 -07:00
parent 31de8c902f
commit b7ed17742e
2 changed files with 61 additions and 0 deletions

View File

@ -6,5 +6,8 @@ scan: main.cpp scanner.cpp
scanner.cpp: scanner.l scanner.cpp: scanner.l
flex -o scanner.cpp scanner.l flex -o scanner.cpp scanner.l
parser.tab.cpp: parser.y
bison -d parser.y
clean: clean:
rm -f scan scanner.cpp rm -f scan scanner.cpp

58
parser.y Normal file
View File

@ -0,0 +1,58 @@
%{
#include <string>
%}
%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 {}
;
%%