mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-25 20:50:12 +01:00
- `Kind` enumerator names always match the corresponding factory function, accessor, and type names (if any). - All abbreviations in those names are expanded. - Those names always have a suffix to disambiguate expressions from values. `VarTV` is excluded from these changes because there's a pending PR to remove it.
23 lines
713 B
C++
23 lines
713 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/syntax/paren_contents.h"
|
|
|
|
namespace Carbon {
|
|
|
|
const Expression* ParenContents::AsExpression(int line_number) const {
|
|
if (fields_.size() == 1 && fields_.front().name == "" &&
|
|
has_trailing_comma_ == HasTrailingComma::No) {
|
|
return new Expression(*fields_.front().expression);
|
|
} else {
|
|
return AsTuple(line_number);
|
|
}
|
|
}
|
|
|
|
const Expression* ParenContents::AsTuple(int line_number) const {
|
|
return Expression::MakeTupleLiteral(line_number, fields_);
|
|
}
|
|
|
|
} // namespace Carbon
|