Files
carbon-lang/executable_semantics/ast/field_list.cpp
T
Geoff RomerandJeremy G. Siek 8b3bb7c5e9 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>
2021-03-01 10:13:53 -05:00

30 lines
817 B
C++

// 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