mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-25 08:40:10 +01:00
* 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>
30 lines
817 B
C++
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
|