Adjust grammar to allow for broader range of type inputs.
This commit is contained in:
parent
207efc7ded
commit
50326ffcc3
14
11/parser.y
14
11/parser.y
|
@ -41,7 +41,7 @@ extern yy::parser::symbol_type yylex();
|
||||||
%type <std::vector<branch_ptr>> branches
|
%type <std::vector<branch_ptr>> branches
|
||||||
%type <std::vector<constructor_ptr>> constructors
|
%type <std::vector<constructor_ptr>> constructors
|
||||||
%type <std::vector<parsed_type_ptr>> typeList
|
%type <std::vector<parsed_type_ptr>> typeList
|
||||||
%type <parsed_type_ptr> type nullaryType
|
%type <parsed_type_ptr> type nullaryType typeListElement
|
||||||
%type <ast_ptr> aAdd aMul case app appBase
|
%type <ast_ptr> aAdd aMul case app appBase
|
||||||
%type <definition_data_ptr> data
|
%type <definition_data_ptr> data
|
||||||
%type <definition_defn_ptr> defn
|
%type <definition_defn_ptr> defn
|
||||||
|
@ -146,12 +146,18 @@ type
|
||||||
;
|
;
|
||||||
|
|
||||||
nullaryType
|
nullaryType
|
||||||
: OPAREN UID typeList CPAREN { $$ = parsed_type_ptr(new parsed_type_app(std::move($2), std::move($3))); }
|
: UID typeList { $$ = parsed_type_ptr(new parsed_type_app(std::move($1), std::move($2))); }
|
||||||
| UID { $$ = parsed_type_ptr(new parsed_type_app(std::move($1), { })); }
|
| LID { $$ = parsed_type_ptr(new parsed_type_var(std::move($1))); }
|
||||||
|
| OPAREN type CPAREN { $$ = std::move($2); }
|
||||||
|
;
|
||||||
|
|
||||||
|
typeListElement
|
||||||
|
: OPAREN type CPAREN { $$ = std::move($2); }
|
||||||
|
| UID { $$ = parsed_type_ptr(new parsed_type_app(std::move($1), {})); }
|
||||||
| LID { $$ = parsed_type_ptr(new parsed_type_var(std::move($1))); }
|
| LID { $$ = parsed_type_ptr(new parsed_type_var(std::move($1))); }
|
||||||
;
|
;
|
||||||
|
|
||||||
typeList
|
typeList
|
||||||
: %empty { $$ = std::vector<parsed_type_ptr>(); }
|
: %empty { $$ = std::vector<parsed_type_ptr>(); }
|
||||||
| typeList type { $$ = std::move($1); $$.push_back(std::move($2)); }
|
| typeList typeListElement { $$ = std::move($1); $$.push_back(std::move($2)); }
|
||||||
;
|
;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user