mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-25 09:30:11 +01:00
The intent of this approach is to eliminate recursion limits as a barrier for the parser. While it may not be urgent to address, I want to avoid pouring effort into a parser approach that we don't think will be usable long-term. Right now this is passing a minor set of tests. It's intended to be enough to show how I'm thinking about flow control for the parser. I'm manually switching back and forth because it seemed like the easiest approach that avoids duplicating tests.
20 lines
552 B
C++
20 lines
552 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 "toolchain/parser/parser_state.h"
|
|
|
|
#include "llvm/ADT/StringRef.h"
|
|
|
|
namespace Carbon {
|
|
|
|
auto ParserState::name() const -> llvm::StringRef {
|
|
static constexpr llvm::StringLiteral Names[] = {
|
|
#define CARBON_PARSER_STATE(Name) #Name,
|
|
#include "toolchain/parser/parser_state.def"
|
|
};
|
|
return Names[static_cast<int>(state_)];
|
|
}
|
|
|
|
} // namespace Carbon
|