Fix type errors in function calls (#308)

* Make `field_list` always a list.

* Create separate `paren_expression` and `tuple` nonterminals

* Rename expression_or_field_list.* to field_list.*

Co-authored-by: Jeremy G. Siek <jsiek@indiana.edu>
This commit is contained in:
Geoff Romer
2021-03-01 10:13:53 -05:00
committed by GitHub
co-authored by Jeremy G. Siek
parent bf6bb800c4
commit 8b3bb7c5e9
7 changed files with 83 additions and 107 deletions
+29
View File
@@ -0,0 +1,29 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#include "executable_semantics/ast/field_list.h"
namespace Carbon {
auto MakeFieldList(std::list<std::pair<std::string, Expression*>>* fields)
-> FieldList* {
auto e = new FieldList();
e->fields = fields;
return e;
}
auto MakeConsField(FieldList* e1, FieldList* e2) -> FieldList* {
auto fields = new std::list<std::pair<std::string, Expression*>>();
for (auto& field : *e1->fields) {
fields->push_back(field);
}
for (auto& field : *e2->fields) {
fields->push_back(field);
}
auto result = MakeFieldList(fields);
result->has_explicit_comma = true;
return result;
}
} // namespace Carbon