mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 14:41:06 +01:00
Validate parse nodes correspond to expected tokens (#3295)
Can specify which tokens are allowed generally, and any additional tokens that only occur when the parse node has an error. --------- Co-authored-by: Richard Smith <richard@metafoo.co.uk>
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include <cstdint>
|
||||
|
||||
#include "common/enum_base.h"
|
||||
#include "toolchain/lex/token_kind.h"
|
||||
|
||||
namespace Carbon::Parse {
|
||||
|
||||
@@ -44,6 +45,11 @@ class NodeKind : public CARBON_ENUM_BASE(NodeKind) {
|
||||
// We expect the parse node kind to fit compactly into 8 bits.
|
||||
static_assert(sizeof(NodeKind) == 1, "Kind objects include padding!");
|
||||
|
||||
// Validates that a `parse_node_kind` parser node can be generated for a
|
||||
// `lex_token_kind` lexer token.
|
||||
void CheckNodeMatchesLexerToken(NodeKind parse_node_kind,
|
||||
Lex::TokenKind lex_token_kind, bool has_error);
|
||||
|
||||
} // namespace Carbon::Parse
|
||||
|
||||
#endif // CARBON_TOOLCHAIN_PARSE_NODE_KIND_H_
|
||||
|
||||
Reference in New Issue
Block a user