mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-25 22:02:28 +01:00
This has two goals: 1) It allows us to simplify and remove special cases from the parser: when we expect a particular token next, we can just check for it without needing a special case for end-of-file. 2) It gives us a token to use as a position when emitting diagnostics at the end of the file. Centralize all updating of `position` to `Consume` and `SkipTo`, so that we can in a single place ensure that we never go past the EOF token.
27 lines
1014 B
Modula-2
27 lines
1014 B
Modula-2
// 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
|
|
//
|
|
// Note that this is an X-macro header.
|
|
//
|
|
// It does not use `#include` guards, and instead is designed to be `#include`ed
|
|
// after the x-macro is defined in order for its inclusion to expand to the
|
|
// desired output. The x-macro for this header is `CARBON_PARSE_NODE_KIND`. The
|
|
// definition provided will be removed at the end of this file to clean up.
|
|
|
|
#ifndef CARBON_PARSE_NODE_KIND
|
|
#error "Must define the x-macro to use this file."
|
|
#endif
|
|
|
|
CARBON_PARSE_NODE_KIND(CodeBlockEnd)
|
|
CARBON_PARSE_NODE_KIND(CodeBlock)
|
|
CARBON_PARSE_NODE_KIND(DeclarationEnd)
|
|
CARBON_PARSE_NODE_KIND(EmptyDeclaration)
|
|
CARBON_PARSE_NODE_KIND(FunctionDeclaration)
|
|
CARBON_PARSE_NODE_KIND(Identifier)
|
|
CARBON_PARSE_NODE_KIND(ParameterListEnd)
|
|
CARBON_PARSE_NODE_KIND(ParameterList)
|
|
CARBON_PARSE_NODE_KIND(FileEnd)
|
|
|
|
#undef CARBON_PARSE_NODE_KIND
|