Address listed flaws in implementation

This commit is contained in:
2019-08-06 14:24:26 -07:00
parent 34e967f364
commit 8450e2c35d
4 changed files with 47 additions and 11 deletions

View File

@@ -35,10 +35,12 @@ extern yy::parser::symbol_type yylex();
%type <std::vector<std::string>> lowercaseParams
%type <std::vector<definition_ptr>> program definitions
%type <std::vector<branch_ptr>> branches
%type <std::vector<constructor_ptr>> constructors
%type <ast_ptr> aAdd aMul case app appBase
%type <definition_ptr> definition
%type <definition_ptr> definition defn data
%type <branch_ptr> branch
%type <pattern_ptr> pattern
%type <constructor_ptr> constructor
%start program
@@ -54,6 +56,11 @@ definitions
;
definition
: defn { $$ = std::move($1); }
| data { $$ = std::move($1); }
;
defn
: DEFN LID lowercaseParams EQUAL OCURLY aAdd CCURLY
{ $$ = definition_ptr(
new definition_defn(std::move($2), std::move($3), std::move($6))); }
@@ -109,3 +116,20 @@ pattern
| UID lowercaseParams
{ $$ = pattern_ptr(new pattern_constr(std::move($1), std::move($2))); }
;
data
: DATA UID EQUAL OCURLY constructors CCURLY
{ $$ = definition_ptr(new definition_data(std::move($2), std::move($5))); }
;
constructors
: constructors COMMA constructor { $$ = std::move($1); $$.push_back(std::move($3)); }
| constructor
{ $$ = std::vector<constructor_ptr>(); $$.push_back(std::move($1)); }
;
constructor
: UID lowercaseParams
{ $$ = constructor_ptr(new constructor(std::move($1), std::move($2))); }
;