mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
Support parsing and testing unimplemented expressions (#957)
Co-authored-by: Jon Meow <46229924+jonmeow@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
co-authored by
Jon Meow
parent
be0c1e9da6
commit
dc5e62fc7a
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "executable_semantics/ast/declaration.h"
|
||||
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
#include "llvm/Support/Casting.h"
|
||||
|
||||
namespace Carbon {
|
||||
@@ -32,7 +33,7 @@ void Declaration::Print(llvm::raw_ostream& out) const {
|
||||
const auto& choice = cast<ChoiceDeclaration>(*this);
|
||||
out << "choice " << choice.name() << " {\n";
|
||||
for (Nonnull<const AlternativeSignature*> alt : choice.alternatives()) {
|
||||
out << "alt " << alt->name() << " " << alt->signature() << ";\n";
|
||||
out << *alt << ";\n";
|
||||
}
|
||||
out << "}\n";
|
||||
break;
|
||||
@@ -46,6 +47,10 @@ void Declaration::Print(llvm::raw_ostream& out) const {
|
||||
}
|
||||
}
|
||||
|
||||
void GenericBinding::Print(llvm::raw_ostream& out) const {
|
||||
out << name() << ":! " << type();
|
||||
}
|
||||
|
||||
void ReturnTerm::Print(llvm::raw_ostream& out) const {
|
||||
switch (kind_) {
|
||||
case ReturnKind::Omitted:
|
||||
@@ -63,14 +68,9 @@ void FunctionDeclaration::PrintDepth(int depth, llvm::raw_ostream& out) const {
|
||||
out << "fn " << name_ << " ";
|
||||
if (!deduced_parameters_.empty()) {
|
||||
out << "[";
|
||||
unsigned int i = 0;
|
||||
llvm::ListSeparator sep;
|
||||
for (Nonnull<const GenericBinding*> deduced : deduced_parameters_) {
|
||||
if (i != 0) {
|
||||
out << ", ";
|
||||
}
|
||||
out << deduced->name() << ":! ";
|
||||
deduced->type().Print(out);
|
||||
++i;
|
||||
out << sep << *deduced;
|
||||
}
|
||||
out << "]";
|
||||
}
|
||||
@@ -84,4 +84,8 @@ void FunctionDeclaration::PrintDepth(int depth, llvm::raw_ostream& out) const {
|
||||
}
|
||||
}
|
||||
|
||||
void AlternativeSignature::Print(llvm::raw_ostream& out) const {
|
||||
out << "alt " << name() << " " << signature();
|
||||
}
|
||||
|
||||
} // namespace Carbon
|
||||
|
||||
Reference in New Issue
Block a user