Switch Clause to Ptr (#800)

This is consistent with other lists, doesn't seem to benefit from being a Ptr.
This commit is contained in:
Jon Meow
2021-09-01 15:19:58 -07:00
committed by GitHub
parent 9f67c4b9a8
commit 5f8b231322
5 changed files with 24 additions and 33 deletions
+6 -15
View File
@@ -128,8 +128,8 @@
%type <ParenContents<Pattern>> paren_pattern_contents
%type <BisonWrap<std::pair<std::string, Ptr<const Expression>>>> alternative
%type <std::list<std::pair<std::string, Ptr<const Expression>>>> alternative_list
%type <std::pair<Ptr<const Pattern>, Ptr<const Statement>>*> clause
%type <std::list<std::pair<Ptr<const Pattern>, Ptr<const Statement>>>*> clause_list
%type <BisonWrap<std::pair<Ptr<const Pattern>, Ptr<const Statement>>>> clause
%type <std::list<std::pair<Ptr<const Pattern>, Ptr<const Statement>>>> clause_list
%token
// Most tokens have their spelling defined in lexer.lpp.
@@ -460,31 +460,22 @@ maybe_empty_tuple_pattern:
;
clause:
CASE pattern DOUBLE_ARROW statement
{
$$ = global_arena
->RawNew<std::pair<Ptr<const Pattern>, Ptr<const Statement>>>(
$2, $4);
}
{ $$ = std::pair<Ptr<const Pattern>, Ptr<const Statement>>($2, $4); }
| DEFAULT DOUBLE_ARROW statement
{
auto vp = global_arena -> New<BindingPattern>(
context.SourceLoc(), std::nullopt,
global_arena->New<AutoPattern>(context.SourceLoc()));
$$ = global_arena
->RawNew<std::pair<Ptr<const Pattern>, Ptr<const Statement>>>(
vp, $3);
$$ = std::pair<Ptr<const Pattern>, Ptr<const Statement>>(vp, $3);
}
;
clause_list:
// Empty
{
$$ = global_arena->RawNew<
std::list<std::pair<Ptr<const Pattern>, Ptr<const Statement>>>>();
}
{ $$ = std::list<std::pair<Ptr<const Pattern>, Ptr<const Statement>>>(); }
| clause clause_list
{
$$ = $2;
$$->push_front(*$1);
$$.push_front($1);
}
;
statement: