Backport fix for parser to post 2.

This commit is contained in:
Danila Fedorin 2019-08-26 00:14:45 -07:00
parent c2df5fdc78
commit 469cabda14

View File

@ -32,7 +32,7 @@ extern yy::parser::symbol_type yylex();
%define api.value.type variant
%define api.token.constructor
%type <std::vector<std::string>> lowercaseParams
%type <std::vector<std::string>> lowercaseParams uppercaseParams
%type <std::vector<definition_ptr>> program definitions
%type <std::vector<branch_ptr>> branches
%type <std::vector<constructor_ptr>> constructors
@ -71,6 +71,11 @@ lowercaseParams
| lowercaseParams LID { $$ = std::move($1); $$.push_back(std::move($2)); }
;
uppercaseParams
: %empty { $$ = std::vector<std::string>(); }
| uppercaseParams UID { $$ = std::move($1); $$.push_back(std::move($2)); }
;
aAdd
: aAdd PLUS aMul { $$ = ast_ptr(new ast_binop(PLUS, std::move($1), std::move($3))); }
| aAdd MINUS aMul { $$ = ast_ptr(new ast_binop(MINUS, std::move($1), std::move($3))); }
@ -102,7 +107,7 @@ case
;
branches
: branches COMMA branch { $$ = std::move($1); $1.push_back(std::move($3)); }
: branches branch { $$ = std::move($1); $1.push_back(std::move($2)); }
| branch { $$ = std::vector<branch_ptr>(); $$.push_back(std::move($1));}
;
@ -129,7 +134,7 @@ constructors
;
constructor
: UID lowercaseParams
: UID uppercaseParams
{ $$ = constructor_ptr(new constructor(std::move($1), std::move($2))); }
;