node_kind.def 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // This is an X-macro header. It does not use `#include` guards, and instead is
  6. // designed to be `#include`ed after the x-macro is defined in order for its
  7. // inclusion to expand to the desired output. Macro definitions are cleaned up
  8. // at the end of this file.
  9. //
  10. // Supported x-macros are:
  11. // - CARBON_PARSE_NODE_KIND(Name)
  12. // Used as a fallback if other macros are missing.
  13. // - CARBON_PARSE_NODE_KIND_BRACKET(Name, BracketName, LexTokenKind)
  14. // Defines a bracketed node kind. BracketName should refer to the node
  15. // kind that is the _start_ of the bracketed range.
  16. // - CARBON_PARSE_NODE_KIND_CHILD_COUNT(Name, ChildCount, LexTokenKind)
  17. // Defines a parse node with a set number of children, often 0. This count
  18. // must be correct even when the node contains errors.
  19. // - CARBON_PARSE_NODE_KIND_PREFIX_OPERATOR(Name)
  20. // Defines a parse node for a prefix operator, with the Name as token.
  21. // - CARBON_PARSE_NODE_KIND_INFIX_OPERATOR(Name)
  22. // Defines a parse node for an infix operator, with the Name as token.
  23. // - CARBON_PARSE_NODE_KIND_POSTFIX_OPERATOR(Name)
  24. // Defines a parse node for a postfix operator, with the Name as token.
  25. // - CARBON_PARSE_NODE_KIND_TOKEN_LITERAL(Name, LexTokenKind)
  26. // Defines a parse node that corresponds to a token that is a single-token
  27. // literal. The token is wrapped for LexTokenKinds.
  28. // - CARBON_PARSE_NODE_KIND_TOKEN_MODIFIER(Name)
  29. // A token-based modifier. The Name is the TokenKind, and will be appended
  30. // with "Modifier" for the parse kind.
  31. //
  32. // LexTokenKind indicates the token kind required on a valid node.
  33. // It will be either `kind_name` to indicate it's required even if the node is
  34. // an error, or `CARBON_IF_VALID(kind_name)` to indicate that the kind is
  35. // not enforced on error. A token kind of `Error` may be used if the kind should
  36. // never be enforced; this should only be used when the node is either not in
  37. // trees (`Placeholder`) or is always invalid (such as `InvalidParse`).
  38. //
  39. // This tree represents the subset relationship between these macros, where if a
  40. // specific x-macro isn't defined, it'll fall back to the parent macro.
  41. //
  42. // Parse nodes are clustered based on language feature. Comments will show their
  43. // relationship in postorder, using indentation for child node relationships.
  44. #if !(defined(CARBON_PARSE_NODE_KIND) || \
  45. (defined(CARBON_PARSE_NODE_KIND_BRACKET) && \
  46. defined(CARBON_PARSE_NODE_KIND_CHILD_COUNT)))
  47. #error "Must define CARBON_PARSE_NODE_KIND family x-macros to use this file."
  48. #endif
  49. // The BRACKET and CHILD_COUNT macros will use CARBON_PARSE_NODE_KIND by default
  50. // when undefined.
  51. #ifndef CARBON_PARSE_NODE_KIND_BRACKET
  52. #define CARBON_PARSE_NODE_KIND_BRACKET(Name, ...) CARBON_PARSE_NODE_KIND(Name)
  53. #endif
  54. #ifndef CARBON_PARSE_NODE_KIND_CHILD_COUNT
  55. #define CARBON_PARSE_NODE_KIND_CHILD_COUNT(Name, ...) \
  56. CARBON_PARSE_NODE_KIND(Name)
  57. #endif
  58. // This is expected to be used with something like:
  59. //
  60. // // Use x-macros to handle modifier cases.
  61. // #define CARBON_PARSE_NODE_KIND(...)
  62. // #define CARBON_PARSE_NODE_KIND_PREFIX_OPERATOR(Name, ...) <code>
  63. #ifndef CARBON_PARSE_NODE_KIND_PREFIX_OPERATOR
  64. #define CARBON_PARSE_NODE_KIND_PREFIX_OPERATOR(Name) \
  65. CARBON_PARSE_NODE_KIND_CHILD_COUNT(PrefixOperator##Name, 1, Name)
  66. #endif
  67. // This is expected to be used with something like:
  68. //
  69. // // Use x-macros to handle modifier cases.
  70. // #define CARBON_PARSE_NODE_KIND(...)
  71. // #define CARBON_PARSE_NODE_KIND_INFIX_OPERATOR(Name, ...) <code>
  72. #ifndef CARBON_PARSE_NODE_KIND_INFIX_OPERATOR
  73. #define CARBON_PARSE_NODE_KIND_INFIX_OPERATOR(Name) \
  74. CARBON_PARSE_NODE_KIND_CHILD_COUNT(InfixOperator##Name, 2, Name)
  75. #endif
  76. // This is expected to be used with something like:
  77. //
  78. // // Use x-macros to handle modifier cases.
  79. // #define CARBON_PARSE_NODE_KIND(...)
  80. // #define CARBON_PARSE_NODE_KIND_POSTFIX_OPERATOR(Name, ...) <code>
  81. #ifndef CARBON_PARSE_NODE_KIND_POSTFIX_OPERATOR
  82. #define CARBON_PARSE_NODE_KIND_POSTFIX_OPERATOR(Name) \
  83. CARBON_PARSE_NODE_KIND_CHILD_COUNT(PostfixOperator##Name, 1, Name)
  84. #endif
  85. // This is expected to be used with something like:
  86. //
  87. // // Use x-macros to handle literal cases.
  88. // #define CARBON_PARSE_NODE_KIND(...)
  89. // #define CARBON_PARSE_NODE_KIND_TOKEN_LITERAL(Name, ...) <code>
  90. #ifndef CARBON_PARSE_NODE_KIND_TOKEN_LITERAL
  91. #define CARBON_PARSE_NODE_KIND_TOKEN_LITERAL(Name, LexTokenKinds) \
  92. CARBON_PARSE_NODE_KIND_CHILD_COUNT(Name, 0, LexTokenKinds)
  93. #endif
  94. // This is expected to be used with something like:
  95. //
  96. // // Use x-macros to handle modifier cases.
  97. // #define CARBON_PARSE_NODE_KIND(...)
  98. // #define CARBON_PARSE_NODE_KIND_TOKEN_MODIFIER(Name, ...) <code>
  99. #ifndef CARBON_PARSE_NODE_KIND_TOKEN_MODIFIER
  100. #define CARBON_PARSE_NODE_KIND_TOKEN_MODIFIER(Name) \
  101. CARBON_PARSE_NODE_KIND_CHILD_COUNT(Name##Modifier, 0, Name)
  102. #endif
  103. // The start of the file.
  104. CARBON_PARSE_NODE_KIND_CHILD_COUNT(FileStart, 0, FileStart)
  105. // The end of the file.
  106. CARBON_PARSE_NODE_KIND_CHILD_COUNT(FileEnd, 0, FileEnd)
  107. // An invalid parse. Used to balance the parse tree. Always has an error.
  108. CARBON_PARSE_NODE_KIND_CHILD_COUNT(InvalidParse, 0, Error)
  109. // An invalid subtree. Always has an error.
  110. CARBON_PARSE_NODE_KIND_CHILD_COUNT(InvalidParseStart, 0, Error)
  111. CARBON_PARSE_NODE_KIND_BRACKET(InvalidParseSubtree, InvalidParseStart, Error)
  112. // A placeholder node to be replaced; it will never exist in a valid parse tree.
  113. // Its token kind is not enforced even when valid.
  114. CARBON_PARSE_NODE_KIND_CHILD_COUNT(Placeholder, 0, Error)
  115. // An empty declaration, such as `;`.
  116. CARBON_PARSE_NODE_KIND_CHILD_COUNT(EmptyDecl, 0, CARBON_IF_VALID(Semi))
  117. // An identifier name in a non-expression context, such as a declaration.
  118. CARBON_PARSE_NODE_KIND_CHILD_COUNT(IdentifierName, 0,
  119. CARBON_IF_VALID(Identifier))
  120. // An identifier name in an expression context.
  121. CARBON_PARSE_NODE_KIND_CHILD_COUNT(IdentifierNameExpr, 0, Identifier)
  122. // The `self` value and `Self` type identifier keywords. Typically of the form
  123. // `self: Self`.
  124. CARBON_PARSE_NODE_KIND_CHILD_COUNT(SelfValueName, 0, SelfValueIdentifier)
  125. CARBON_PARSE_NODE_KIND_CHILD_COUNT(SelfValueNameExpr, 0, SelfValueIdentifier)
  126. CARBON_PARSE_NODE_KIND_CHILD_COUNT(SelfTypeNameExpr, 0, SelfTypeIdentifier)
  127. // The `base` value keyword, introduced by `base: B`. Typically referenced in
  128. // an expression, as in `x.base` or `{.base = ...}`, but can also be used as a
  129. // declared name, as in `{.base: partial B}`.
  130. CARBON_PARSE_NODE_KIND_CHILD_COUNT(BaseName, 0, Base)
  131. // The `package` keyword in an expression.
  132. CARBON_PARSE_NODE_KIND_CHILD_COUNT(PackageExpr, 0, Package)
  133. // ----------------------------------------------------------------------------
  134. // The comments below follow this pattern:
  135. //
  136. // // Descriptive heading:
  137. // // Child1
  138. // // Child2
  139. // // Parent
  140. //
  141. // In this, `Child1`, `Child2`, and `Parent` are all kinds of parse nodes, which
  142. // are then defined using the `CARBON_PARSE_NODE_KIND_*` macros. They are
  143. // written in postorder, with the indentation showing the tree structure. See
  144. // tree.h for more information.
  145. //
  146. // A parse node kind may be preceded by:
  147. // - `_optional_` if this node (or nodes) may be present or omitted in valid
  148. // parses, depending on which tokens are in the source code.
  149. // - `_repeated_` if this node (or nodes) may be repeated or omitted in valid
  150. // parses, depending on which tokens are in the source code.
  151. // - `_external_:` if this node is the child of multiple kinds of nodes and
  152. // is documented separately.
  153. //
  154. // There is generally a close correspondence between handling of tokens and the
  155. // creation of non-external nodes in a given block.
  156. // ----------------------------------------------------------------------------
  157. // The name of a package or library for `package`, `import`, and `library`.
  158. CARBON_PARSE_NODE_KIND_CHILD_COUNT(PackageName, 0, Identifier)
  159. CARBON_PARSE_NODE_KIND_CHILD_COUNT(LibraryName, 0, StringLiteral)
  160. // `package`:
  161. // PackageIntroducer
  162. // _repeated_ _external_: modifier
  163. // _optional_ _external_: PackageName
  164. // _optional_ _external_: LibrarySpecifier
  165. // PackageDecl
  166. CARBON_PARSE_NODE_KIND_CHILD_COUNT(PackageIntroducer, 0, Package)
  167. CARBON_PARSE_NODE_KIND_BRACKET(PackageDecl, PackageIntroducer,
  168. CARBON_IF_VALID(Semi))
  169. // `import`:
  170. // ImportIntroducer
  171. // _repeated_ _external_: modifier
  172. // _optional_ _external_: PackageName
  173. // _optional_ _external_: LibrarySpecifier
  174. // ImportDecl
  175. CARBON_PARSE_NODE_KIND_CHILD_COUNT(ImportIntroducer, 0, Import)
  176. CARBON_PARSE_NODE_KIND_BRACKET(ImportDecl, ImportIntroducer,
  177. CARBON_IF_VALID(Semi))
  178. // `library` as declaration:
  179. // LibraryIntroducer
  180. // _repeated_ _external_: modifier
  181. // DefaultLibrary or _external_: LibraryName
  182. // LibraryDecl
  183. CARBON_PARSE_NODE_KIND_CHILD_COUNT(DefaultLibrary, 0, Default)
  184. CARBON_PARSE_NODE_KIND_CHILD_COUNT(LibraryIntroducer, 0, Library)
  185. CARBON_PARSE_NODE_KIND_BRACKET(LibraryDecl, LibraryIntroducer,
  186. CARBON_IF_VALID(Semi))
  187. // `library` in `package` or `import`:
  188. // _external_: LibraryName or DefaultLibrary
  189. // LibrarySpecifier
  190. CARBON_PARSE_NODE_KIND_CHILD_COUNT(LibrarySpecifier, 1, Library)
  191. // `export`:
  192. // ExportIntroducer
  193. // _external_: IdentifierName or QualifiedName
  194. // ExportDecl
  195. CARBON_PARSE_NODE_KIND_CHILD_COUNT(ExportIntroducer, 0, Export)
  196. CARBON_PARSE_NODE_KIND_BRACKET(ExportDecl, ExportIntroducer,
  197. CARBON_IF_VALID(Semi))
  198. // `namespace`:
  199. // NamespaceStart
  200. // _repeated_ _external_: modifier
  201. // _external_: IdentifierName or QualifiedName
  202. // Namespace
  203. CARBON_PARSE_NODE_KIND_CHILD_COUNT(NamespaceStart, 0, Namespace)
  204. CARBON_PARSE_NODE_KIND_BRACKET(Namespace, NamespaceStart, CARBON_IF_VALID(Semi))
  205. // A code block:
  206. // CodeBlockStart
  207. // _repeated_ _external_: statement
  208. // CodeBlock
  209. CARBON_PARSE_NODE_KIND_CHILD_COUNT(CodeBlockStart, 0,
  210. CARBON_IF_VALID(OpenCurlyBrace))
  211. CARBON_PARSE_NODE_KIND_BRACKET(CodeBlock, CodeBlockStart,
  212. CARBON_IF_VALID(CloseCurlyBrace))
  213. // `fn` declarations start with a function signature:
  214. //
  215. // FunctionIntroducer
  216. // _repeated_ _external_: modifier
  217. // _external_: IdentifierName or QualifiedName
  218. // _optional_ _external_: ImplicitParamList
  219. // _external_: TuplePattern
  220. // _external_: type expression
  221. // ReturnType
  222. // _function signature_
  223. //
  224. // There are three forms of function declaration:
  225. //
  226. // _function signature_
  227. // FunctionDecl
  228. //
  229. // _function signature_
  230. // FunctionDefinitionStart
  231. // _repeated_ _external_: statement
  232. // FunctionDefinition
  233. //
  234. // _function signature_
  235. // BuiltinFunctionDefinitionStart
  236. // BuiltinName
  237. // BuiltinFunctionDefinition
  238. CARBON_PARSE_NODE_KIND_CHILD_COUNT(FunctionIntroducer, 0, Fn)
  239. CARBON_PARSE_NODE_KIND_CHILD_COUNT(ReturnType, 1, MinusGreater)
  240. CARBON_PARSE_NODE_KIND_BRACKET(FunctionDefinitionStart, FunctionIntroducer,
  241. OpenCurlyBrace)
  242. CARBON_PARSE_NODE_KIND_BRACKET(FunctionDefinition, FunctionDefinitionStart,
  243. CloseCurlyBrace)
  244. CARBON_PARSE_NODE_KIND_BRACKET(FunctionDecl, FunctionIntroducer,
  245. CARBON_IF_VALID(Semi))
  246. CARBON_PARSE_NODE_KIND_BRACKET(BuiltinFunctionDefinitionStart,
  247. FunctionIntroducer, Equal)
  248. CARBON_PARSE_NODE_KIND_CHILD_COUNT(BuiltinName, 0, StringLiteral)
  249. CARBON_PARSE_NODE_KIND_BRACKET(BuiltinFunctionDefinition,
  250. BuiltinFunctionDefinitionStart,
  251. CARBON_IF_VALID(Semi))
  252. // `alias`:
  253. // AliasIntroducer
  254. // _repeated_ _external_: modifier
  255. // _external_: IdentifierName or QualifiedName
  256. // AliasInitializer
  257. // _external_: expression
  258. // Alias
  259. CARBON_PARSE_NODE_KIND_CHILD_COUNT(AliasIntroducer, 0, Alias)
  260. CARBON_PARSE_NODE_KIND_CHILD_COUNT(AliasInitializer, 0, Equal)
  261. CARBON_PARSE_NODE_KIND_BRACKET(Alias, AliasIntroducer, CARBON_IF_VALID(Semi))
  262. // A tuple pattern:
  263. // TuplePatternStart
  264. // _external_: [Generic]BindingPattern
  265. // PatternListComma
  266. // _repeated_
  267. // TuplePattern
  268. //
  269. // Patterns and PatternListComma may repeat with PatternListComma as a
  270. // separator.
  271. CARBON_PARSE_NODE_KIND_CHILD_COUNT(TuplePatternStart, 0, OpenParen)
  272. CARBON_PARSE_NODE_KIND_CHILD_COUNT(PatternListComma, 0, Comma)
  273. CARBON_PARSE_NODE_KIND_BRACKET(TuplePattern, TuplePatternStart, CloseParen)
  274. // An implicit parameter list:
  275. // ImplicitParamListStart
  276. // _external_: [Generic]BindingPattern
  277. // PatternListComma
  278. // _repeated_
  279. // ImplicitParamList
  280. //
  281. // Patterns and PatternListComma may repeat with PatternListComma as a
  282. // separator.
  283. CARBON_PARSE_NODE_KIND_CHILD_COUNT(ImplicitParamListStart, 0, OpenSquareBracket)
  284. CARBON_PARSE_NODE_KIND_BRACKET(ImplicitParamList, ImplicitParamListStart,
  285. CloseSquareBracket)
  286. // An array type, such as `[i32; 3]` or `[i32;]`:
  287. // ArrayExprStart
  288. // _external_: type expression
  289. // ArrayExprSemi
  290. // _optional_ _external_: expression
  291. // ArrayExpr
  292. CARBON_PARSE_NODE_KIND_CHILD_COUNT(ArrayExprStart, 0, OpenSquareBracket)
  293. CARBON_PARSE_NODE_KIND_CHILD_COUNT(ArrayExprSemi, 2, CARBON_IF_VALID(Semi))
  294. CARBON_PARSE_NODE_KIND_BRACKET(ArrayExpr, ArrayExprSemi, CloseSquareBracket)
  295. // A binding pattern, such as `name: Type`:
  296. // IdentifierName or SelfValueName
  297. // _external_: type expression
  298. // [Generic]BindingPattern
  299. // _optional_ Addr
  300. // _optional_ Template
  301. CARBON_PARSE_NODE_KIND_CHILD_COUNT(BindingPattern, 2, CARBON_IF_VALID(Colon))
  302. CARBON_PARSE_NODE_KIND_CHILD_COUNT(CompileTimeBindingPattern, 2, ColonExclaim)
  303. CARBON_PARSE_NODE_KIND_CHILD_COUNT(Addr, 1, Addr)
  304. CARBON_PARSE_NODE_KIND_CHILD_COUNT(Template, 1, Template)
  305. // `let` declarations, including associated constant declarations:
  306. // LetIntroducer
  307. // _repeated_ _external_: modifier
  308. // _external_: BindingPattern or TuplePattern
  309. // LetInitializer
  310. // _external_: expression
  311. // _optional_
  312. // LetDecl
  313. //
  314. // Modifier keywords only appear for `let` declarations, not `let` statements.
  315. //
  316. // The LetInitializer and following expression are paired: either both will be
  317. // present, or neither will.
  318. CARBON_PARSE_NODE_KIND_CHILD_COUNT(LetIntroducer, 0, Let)
  319. CARBON_PARSE_NODE_KIND_CHILD_COUNT(LetInitializer, 0, Equal)
  320. CARBON_PARSE_NODE_KIND_BRACKET(LetDecl, LetIntroducer, CARBON_IF_VALID(Semi))
  321. // `var` and `returned var`:
  322. // VariableIntroducer
  323. // _repeated_ _external_: modifier
  324. // _optional_ ReturnedModifier
  325. // _external_: BindingPattern or TuplePattern
  326. // VariableInitializer
  327. // _external_: expression
  328. // _optional_
  329. // VariableDecl
  330. //
  331. // Access and declaration modifier keywords only appear for `var` declarations,
  332. // whereas the returned modifier only appears on `var` statements.
  333. //
  334. // The VariableInitializer and following expression are paired: either both will
  335. // be present, or neither will.
  336. CARBON_PARSE_NODE_KIND_CHILD_COUNT(VariableIntroducer, 0, CARBON_IF_VALID(Var))
  337. CARBON_PARSE_NODE_KIND_CHILD_COUNT(ReturnedModifier, 0, Returned)
  338. CARBON_PARSE_NODE_KIND_CHILD_COUNT(VariableInitializer, 0, Equal)
  339. CARBON_PARSE_NODE_KIND_BRACKET(VariableDecl, VariableIntroducer,
  340. CARBON_IF_VALID(Semi))
  341. // An expression statement:
  342. // _external_: expression
  343. // ExprStatement
  344. CARBON_PARSE_NODE_KIND_CHILD_COUNT(ExprStatement, 1, CARBON_IF_VALID(Semi))
  345. // `break`:
  346. // BreakStatementStart
  347. // BreakStatement
  348. CARBON_PARSE_NODE_KIND_CHILD_COUNT(BreakStatementStart, 0, Break)
  349. CARBON_PARSE_NODE_KIND_CHILD_COUNT(BreakStatement, 1, CARBON_IF_VALID(Semi))
  350. // `continue`:
  351. // ContinueStatementStart
  352. // ContinueStatement
  353. CARBON_PARSE_NODE_KIND_CHILD_COUNT(ContinueStatementStart, 0, Continue)
  354. CARBON_PARSE_NODE_KIND_CHILD_COUNT(ContinueStatement, 1, CARBON_IF_VALID(Semi))
  355. // `return`:
  356. // ReturnStatementStart
  357. // _optional_ ReturnVarModifier or _external_: expression
  358. // ReturnStatement
  359. CARBON_PARSE_NODE_KIND_CHILD_COUNT(ReturnStatementStart, 0, Return)
  360. CARBON_PARSE_NODE_KIND_CHILD_COUNT(ReturnVarModifier, 0, Var)
  361. CARBON_PARSE_NODE_KIND_BRACKET(ReturnStatement, ReturnStatementStart,
  362. CARBON_IF_VALID(Semi))
  363. // `for`:
  364. // ForHeaderStart
  365. // VariableIntroducer
  366. // _external_: BindingPattern
  367. // ForIn
  368. // _external_: expression
  369. // ForHeader
  370. // _external_: CodeBlock
  371. // ForStatement
  372. //
  373. // Versus a normal `var`, ForIn replaces VariableDecl.
  374. CARBON_PARSE_NODE_KIND_CHILD_COUNT(ForHeaderStart, 0,
  375. CARBON_IF_VALID(OpenParen))
  376. CARBON_PARSE_NODE_KIND_BRACKET(ForIn, VariableIntroducer, CARBON_IF_VALID(In))
  377. CARBON_PARSE_NODE_KIND_BRACKET(ForHeader, ForHeaderStart,
  378. CARBON_IF_VALID(CloseParen))
  379. CARBON_PARSE_NODE_KIND_CHILD_COUNT(ForStatement, 2, For)
  380. // `if` statement + `else`:
  381. // IfConditionStart
  382. // _external_: expression
  383. // IfCondition
  384. // _external_: CodeBlock
  385. // IfStatementElse
  386. // _external_: CodeBlock or IfStatement
  387. // IfStatement
  388. //
  389. // IfStatementElse and the following node are optional based on `else` presence.
  390. CARBON_PARSE_NODE_KIND_CHILD_COUNT(IfConditionStart, 0,
  391. CARBON_IF_VALID(OpenParen))
  392. CARBON_PARSE_NODE_KIND_BRACKET(IfCondition, IfConditionStart,
  393. CARBON_IF_VALID(CloseParen))
  394. CARBON_PARSE_NODE_KIND_CHILD_COUNT(IfStatementElse, 0, Else)
  395. CARBON_PARSE_NODE_KIND_BRACKET(IfStatement, IfCondition, If)
  396. // `while`:
  397. // WhileConditionStart
  398. // _external_: expression
  399. // WhileCondition
  400. // _external_: CodeBlock
  401. // WhileStatement
  402. CARBON_PARSE_NODE_KIND_CHILD_COUNT(WhileConditionStart, 0,
  403. CARBON_IF_VALID(OpenParen))
  404. CARBON_PARSE_NODE_KIND_BRACKET(WhileCondition, WhileConditionStart,
  405. CARBON_IF_VALID(CloseParen))
  406. CARBON_PARSE_NODE_KIND_CHILD_COUNT(WhileStatement, 2, While)
  407. // Index expressions, such as `a[1]`:
  408. // _external_: expression
  409. // IndexExprStart
  410. // _external_: expression
  411. // IndexExpr
  412. CARBON_PARSE_NODE_KIND_CHILD_COUNT(IndexExprStart, 1, OpenSquareBracket)
  413. CARBON_PARSE_NODE_KIND_BRACKET(IndexExpr, IndexExprStart, CloseSquareBracket)
  414. // Parenthesized single expressions, such as `(2)`:
  415. // ParenExprStart
  416. // _external_: expression
  417. // ParenExpr
  418. CARBON_PARSE_NODE_KIND_CHILD_COUNT(ParenExprStart, 0, OpenParen)
  419. CARBON_PARSE_NODE_KIND_BRACKET(ParenExpr, ParenExprStart, CloseParen)
  420. // Tuples, such as `(1, 2)`:
  421. // TupleLiteralStart
  422. // _external_: expression
  423. // TupleLiteralComma
  424. // _repeated_
  425. // TupleLiteral
  426. //
  427. // Expressions and TupleLiteralComma may repeat with TupleLiteralComma as a
  428. // separator.
  429. CARBON_PARSE_NODE_KIND_CHILD_COUNT(TupleLiteralStart, 0, OpenParen)
  430. CARBON_PARSE_NODE_KIND_CHILD_COUNT(TupleLiteralComma, 0, Comma)
  431. CARBON_PARSE_NODE_KIND_BRACKET(TupleLiteral, TupleLiteralStart, CloseParen)
  432. // Call expressions, such as `a()`:
  433. // _external_: expression
  434. // CallExprStart
  435. // _external_: expression
  436. // CallExprComma
  437. // _repeated_
  438. // CallExpr
  439. //
  440. // Exprs and CallExprComma may repeat with CallExprComma as a separator.
  441. CARBON_PARSE_NODE_KIND_CHILD_COUNT(CallExprStart, 1, OpenParen)
  442. CARBON_PARSE_NODE_KIND_CHILD_COUNT(CallExprComma, 0, Comma)
  443. CARBON_PARSE_NODE_KIND_BRACKET(CallExpr, CallExprStart, CloseParen)
  444. // A qualified declaration, such as `a.b`:
  445. // _external_: IdentifierName or QualifiedName
  446. // _external_: IdentifierName
  447. // QualifiedName
  448. //
  449. // TODO: This will eventually more general expressions, for example with
  450. // `GenericType(type_args).ChildType(child_type_args).Name`.
  451. CARBON_PARSE_NODE_KIND_CHILD_COUNT(QualifiedName, 2, Period)
  452. // A member access expression, such as `a.b` or
  453. // `GetObject().(Interface.member)`:
  454. // _external_: lhs expression
  455. // _external_: rhs expression
  456. // MemberAccessExpr
  457. CARBON_PARSE_NODE_KIND_CHILD_COUNT(MemberAccessExpr, 2, Period)
  458. // A pointer member access expression, such as `a->b` or
  459. // `GetObject()->(Interface.member)`:
  460. // _external_: lhs expression
  461. // _external_: rhs expression
  462. // PointerMemberAccessExpr
  463. CARBON_PARSE_NODE_KIND_CHILD_COUNT(PointerMemberAccessExpr, 2, MinusGreater)
  464. // A value literal.
  465. CARBON_PARSE_NODE_KIND_TOKEN_LITERAL(BoolLiteralFalse, False)
  466. CARBON_PARSE_NODE_KIND_TOKEN_LITERAL(BoolLiteralTrue, True)
  467. CARBON_PARSE_NODE_KIND_TOKEN_LITERAL(IntLiteral, IntLiteral)
  468. CARBON_PARSE_NODE_KIND_TOKEN_LITERAL(RealLiteral, RealLiteral)
  469. CARBON_PARSE_NODE_KIND_TOKEN_LITERAL(StringLiteral, StringLiteral)
  470. // A type literal.
  471. CARBON_PARSE_NODE_KIND_TOKEN_LITERAL(BoolTypeLiteral, Bool)
  472. CARBON_PARSE_NODE_KIND_TOKEN_LITERAL(IntTypeLiteral, IntTypeLiteral)
  473. CARBON_PARSE_NODE_KIND_TOKEN_LITERAL(UnsignedIntTypeLiteral,
  474. UnsignedIntTypeLiteral)
  475. CARBON_PARSE_NODE_KIND_TOKEN_LITERAL(FloatTypeLiteral, FloatTypeLiteral)
  476. CARBON_PARSE_NODE_KIND_TOKEN_LITERAL(StringTypeLiteral, StringTypeLiteral)
  477. CARBON_PARSE_NODE_KIND_TOKEN_LITERAL(TypeTypeLiteral, Type)
  478. CARBON_PARSE_NODE_KIND_TOKEN_LITERAL(AutoTypeLiteral, Auto)
  479. // A prefix operator, such as `not`:
  480. // _external_: expression
  481. // PrefixOperator<name>
  482. CARBON_PARSE_NODE_KIND_PREFIX_OPERATOR(Amp)
  483. CARBON_PARSE_NODE_KIND_PREFIX_OPERATOR(Caret)
  484. CARBON_PARSE_NODE_KIND_PREFIX_OPERATOR(Const)
  485. CARBON_PARSE_NODE_KIND_PREFIX_OPERATOR(Not)
  486. CARBON_PARSE_NODE_KIND_PREFIX_OPERATOR(Minus)
  487. CARBON_PARSE_NODE_KIND_PREFIX_OPERATOR(MinusMinus)
  488. CARBON_PARSE_NODE_KIND_PREFIX_OPERATOR(PlusPlus)
  489. CARBON_PARSE_NODE_KIND_PREFIX_OPERATOR(Star)
  490. // An infix operator, such as `+`:
  491. // _external_: lhs expression
  492. // _external_: rhs expression
  493. // InfixOperator<name>
  494. CARBON_PARSE_NODE_KIND_INFIX_OPERATOR(Amp)
  495. CARBON_PARSE_NODE_KIND_INFIX_OPERATOR(AmpEqual)
  496. CARBON_PARSE_NODE_KIND_INFIX_OPERATOR(As)
  497. CARBON_PARSE_NODE_KIND_INFIX_OPERATOR(Caret)
  498. CARBON_PARSE_NODE_KIND_INFIX_OPERATOR(CaretEqual)
  499. CARBON_PARSE_NODE_KIND_INFIX_OPERATOR(Equal)
  500. CARBON_PARSE_NODE_KIND_INFIX_OPERATOR(EqualEqual)
  501. CARBON_PARSE_NODE_KIND_INFIX_OPERATOR(ExclaimEqual)
  502. CARBON_PARSE_NODE_KIND_INFIX_OPERATOR(Greater)
  503. CARBON_PARSE_NODE_KIND_INFIX_OPERATOR(GreaterEqual)
  504. CARBON_PARSE_NODE_KIND_INFIX_OPERATOR(GreaterGreater)
  505. CARBON_PARSE_NODE_KIND_INFIX_OPERATOR(GreaterGreaterEqual)
  506. CARBON_PARSE_NODE_KIND_INFIX_OPERATOR(Less)
  507. CARBON_PARSE_NODE_KIND_INFIX_OPERATOR(LessEqual)
  508. CARBON_PARSE_NODE_KIND_INFIX_OPERATOR(LessEqualGreater)
  509. CARBON_PARSE_NODE_KIND_INFIX_OPERATOR(LessLess)
  510. CARBON_PARSE_NODE_KIND_INFIX_OPERATOR(LessLessEqual)
  511. CARBON_PARSE_NODE_KIND_INFIX_OPERATOR(Minus)
  512. CARBON_PARSE_NODE_KIND_INFIX_OPERATOR(MinusEqual)
  513. CARBON_PARSE_NODE_KIND_INFIX_OPERATOR(Percent)
  514. CARBON_PARSE_NODE_KIND_INFIX_OPERATOR(PercentEqual)
  515. CARBON_PARSE_NODE_KIND_INFIX_OPERATOR(Pipe)
  516. CARBON_PARSE_NODE_KIND_INFIX_OPERATOR(PipeEqual)
  517. CARBON_PARSE_NODE_KIND_INFIX_OPERATOR(Plus)
  518. CARBON_PARSE_NODE_KIND_INFIX_OPERATOR(PlusEqual)
  519. CARBON_PARSE_NODE_KIND_INFIX_OPERATOR(Slash)
  520. CARBON_PARSE_NODE_KIND_INFIX_OPERATOR(SlashEqual)
  521. CARBON_PARSE_NODE_KIND_INFIX_OPERATOR(Star)
  522. CARBON_PARSE_NODE_KIND_INFIX_OPERATOR(StarEqual)
  523. // A postfix operator, currently only `*`:
  524. // _external_: expression
  525. // PostfixOperator<name>
  526. CARBON_PARSE_NODE_KIND_POSTFIX_OPERATOR(Star)
  527. // A short-circuiting infix operator, such as `and`:
  528. // _external_: expression
  529. // ShortCircuitOperand(And|Or)
  530. // _external_: expression
  531. // ShortCircuitOperand(And|Or)
  532. CARBON_PARSE_NODE_KIND_CHILD_COUNT(ShortCircuitOperandAnd, 1, And)
  533. CARBON_PARSE_NODE_KIND_CHILD_COUNT(ShortCircuitOperandOr, 1, Or)
  534. CARBON_PARSE_NODE_KIND_CHILD_COUNT(ShortCircuitOperatorAnd, 2, And)
  535. CARBON_PARSE_NODE_KIND_CHILD_COUNT(ShortCircuitOperatorOr, 2, Or)
  536. // `if` expression + `then` + `else`:
  537. // _external_: expression
  538. // IfExprIf
  539. // _external_: expression
  540. // IfExprThen
  541. // _external_: expression
  542. // IfExprElse
  543. CARBON_PARSE_NODE_KIND_CHILD_COUNT(IfExprIf, 1, If)
  544. CARBON_PARSE_NODE_KIND_CHILD_COUNT(IfExprThen, 1, Then)
  545. CARBON_PARSE_NODE_KIND_CHILD_COUNT(IfExprElse, 3, CARBON_IF_VALID(Else))
  546. // Struct literals, such as `{.a = 0}`:
  547. // StructLiteralStart
  548. // _external_: IdentifierName or BaseName
  549. // StructFieldDesignator
  550. // _external_: expression
  551. // StructField
  552. // StructComma
  553. // _repeated_
  554. // StructLiteral
  555. //
  556. // Struct type literals, such as `{.a: i32}`:
  557. // StructTypeLiteralStart
  558. // _external_: IdentifierName or BaseName
  559. // StructFieldDesignator
  560. // _external_: type expression
  561. // StructTypeField
  562. // StructComma
  563. // _repeated_
  564. // StructTypeLiteral
  565. //
  566. // Elements (StructField and StructTypeField, respectively) and StructComma
  567. // may repeat with StructComma as a separator.
  568. //
  569. // When a valid StructTypeField or StructField cannot be formed, elements
  570. // may be replaced by InvalidParse, which may have a preceding sibling
  571. // StructFieldDesignator if one was successfully parsed.
  572. CARBON_PARSE_NODE_KIND_CHILD_COUNT(StructLiteralStart, 0, OpenCurlyBrace)
  573. CARBON_PARSE_NODE_KIND_CHILD_COUNT(StructTypeLiteralStart, 0, OpenCurlyBrace)
  574. CARBON_PARSE_NODE_KIND_CHILD_COUNT(StructFieldDesignator, 1, Period)
  575. CARBON_PARSE_NODE_KIND_CHILD_COUNT(StructField, 2, Equal)
  576. CARBON_PARSE_NODE_KIND_CHILD_COUNT(StructTypeField, 2, Colon)
  577. CARBON_PARSE_NODE_KIND_CHILD_COUNT(StructComma, 0, Comma)
  578. CARBON_PARSE_NODE_KIND_BRACKET(StructLiteral, StructLiteralStart,
  579. CloseCurlyBrace)
  580. CARBON_PARSE_NODE_KIND_BRACKET(StructTypeLiteral, StructTypeLiteralStart,
  581. CloseCurlyBrace)
  582. // Various modifiers. These are all a single token.
  583. CARBON_PARSE_NODE_KIND_TOKEN_MODIFIER(Abstract)
  584. CARBON_PARSE_NODE_KIND_TOKEN_MODIFIER(Base)
  585. CARBON_PARSE_NODE_KIND_TOKEN_MODIFIER(Default)
  586. CARBON_PARSE_NODE_KIND_TOKEN_MODIFIER(Export)
  587. CARBON_PARSE_NODE_KIND_TOKEN_MODIFIER(Extend)
  588. CARBON_PARSE_NODE_KIND_TOKEN_MODIFIER(Extern)
  589. CARBON_PARSE_NODE_KIND_TOKEN_MODIFIER(Final)
  590. CARBON_PARSE_NODE_KIND_TOKEN_MODIFIER(Impl)
  591. CARBON_PARSE_NODE_KIND_TOKEN_MODIFIER(Private)
  592. CARBON_PARSE_NODE_KIND_TOKEN_MODIFIER(Protected)
  593. CARBON_PARSE_NODE_KIND_TOKEN_MODIFIER(Virtual)
  594. // `class`:
  595. // ClassIntroducer
  596. // _repeated_ _external_: modifier
  597. // _external_: IdentifierName or QualifiedName
  598. // _optional_ _external_: ImplicitParamList
  599. // _optional_ _external_: TuplePattern
  600. // ClassDefinitionStart
  601. // _external_: declarations
  602. // ClassDefinition
  603. //
  604. // The above is the structure for a definition; for a declaration,
  605. // ClassDefinitionStart and later nodes are removed and replaced by
  606. // ClassDecl.
  607. CARBON_PARSE_NODE_KIND_CHILD_COUNT(ClassIntroducer, 0, Class)
  608. CARBON_PARSE_NODE_KIND_BRACKET(ClassDefinitionStart, ClassIntroducer,
  609. OpenCurlyBrace)
  610. CARBON_PARSE_NODE_KIND_BRACKET(ClassDefinition, ClassDefinitionStart,
  611. CloseCurlyBrace)
  612. CARBON_PARSE_NODE_KIND_BRACKET(ClassDecl, ClassIntroducer,
  613. CARBON_IF_VALID(Semi))
  614. // `adapt`:
  615. // AdaptIntroducer
  616. // _repeated_ _external_: modifier
  617. // _external_: expression
  618. // AdaptDecl
  619. CARBON_PARSE_NODE_KIND_CHILD_COUNT(AdaptIntroducer, 0, Adapt)
  620. CARBON_PARSE_NODE_KIND_BRACKET(AdaptDecl, AdaptIntroducer,
  621. CARBON_IF_VALID(Semi))
  622. // `base`:
  623. // BaseIntroducer
  624. // _repeated_ _external_: modifier
  625. // BaseColon
  626. // _external_: expression
  627. // BaseDecl
  628. CARBON_PARSE_NODE_KIND_CHILD_COUNT(BaseIntroducer, 0, Base)
  629. CARBON_PARSE_NODE_KIND_CHILD_COUNT(BaseColon, 0, Colon)
  630. CARBON_PARSE_NODE_KIND_BRACKET(BaseDecl, BaseIntroducer, CARBON_IF_VALID(Semi))
  631. // `interface`:
  632. // InterfaceIntroducer
  633. // _repeated_ _external_: modifier
  634. // _external_: IdentifierName or QualifiedName
  635. // _optional_ _external_: ImplicitParamList
  636. // _optional_ _external_: TuplePattern
  637. // InterfaceDefinitionStart
  638. // _external_: declarations
  639. // InterfaceDefinition
  640. //
  641. // The above is the structure for a definition; for a declaration,
  642. // InterfaceDefinitionStart and later nodes are removed and replaced by
  643. // InterfaceDecl.
  644. CARBON_PARSE_NODE_KIND_CHILD_COUNT(InterfaceIntroducer, 0, Interface)
  645. CARBON_PARSE_NODE_KIND_BRACKET(InterfaceDefinitionStart, InterfaceIntroducer,
  646. OpenCurlyBrace)
  647. CARBON_PARSE_NODE_KIND_BRACKET(InterfaceDefinition, InterfaceDefinitionStart,
  648. CloseCurlyBrace)
  649. CARBON_PARSE_NODE_KIND_BRACKET(InterfaceDecl, InterfaceIntroducer,
  650. CARBON_IF_VALID(Semi))
  651. // `impl ... as`:
  652. // ImplIntroducer
  653. // _repeated_ _external_: modifier
  654. // _optional_ _external_: ImplForall
  655. // _optional_ _external_: expression
  656. // _external_: DefaultSelfImplAs or TypeImplAs
  657. // _external_: expression
  658. // ImplDefinitionStart
  659. // _external_: declarations
  660. // ImplDefinition
  661. //
  662. // The above is the structure for a definition; for a declaration,
  663. // ImplDefinitionStart and later nodes are removed and replaced by
  664. // ImplDecl.
  665. CARBON_PARSE_NODE_KIND_CHILD_COUNT(ImplIntroducer, 0, Impl)
  666. CARBON_PARSE_NODE_KIND_BRACKET(ImplDefinitionStart, ImplIntroducer,
  667. OpenCurlyBrace)
  668. CARBON_PARSE_NODE_KIND_BRACKET(ImplDefinition, ImplDefinitionStart,
  669. CloseCurlyBrace)
  670. CARBON_PARSE_NODE_KIND_BRACKET(ImplDecl, ImplIntroducer, CARBON_IF_VALID(Semi))
  671. // `forall ...`:
  672. // _external_: ImplicitParamList
  673. // ImplForall
  674. CARBON_PARSE_NODE_KIND_CHILD_COUNT(ImplForall, 1, Forall)
  675. // `... as`:
  676. // _external_: expression
  677. // TypeImplAs
  678. CARBON_PARSE_NODE_KIND_CHILD_COUNT(TypeImplAs, 1, As)
  679. // `as` without a type before it
  680. CARBON_PARSE_NODE_KIND_CHILD_COUNT(DefaultSelfImplAs, 0, As)
  681. // `constraint`:
  682. // NamedConstraintIntroducer
  683. // _repeated_ _external_: modifier
  684. // _external_: IdentifierName or QualifiedName
  685. // _optional_ _external_: ImplicitParamList
  686. // _optional_ _external_: TuplePattern
  687. // NamedConstraintDefinitionStart
  688. // _external_: declarations
  689. // NamedConstraintDefinition
  690. //
  691. // The above is the structure for a definition; for a declaration,
  692. // NamedConstraintDefinitionStart and later nodes are removed and replaced by
  693. // NamedConstraintDecl.
  694. CARBON_PARSE_NODE_KIND_CHILD_COUNT(NamedConstraintIntroducer, 0, Constraint)
  695. CARBON_PARSE_NODE_KIND_BRACKET(NamedConstraintDefinitionStart,
  696. NamedConstraintIntroducer, OpenCurlyBrace)
  697. CARBON_PARSE_NODE_KIND_BRACKET(NamedConstraintDefinition,
  698. NamedConstraintDefinitionStart, CloseCurlyBrace)
  699. CARBON_PARSE_NODE_KIND_BRACKET(NamedConstraintDecl, NamedConstraintIntroducer,
  700. CARBON_IF_VALID(Semi))
  701. // `choice`:
  702. // ChoiceIntroducer
  703. // _external_: IdentifierName or QualifiedDecl
  704. // ChoiceDefinitionStart
  705. // _optional_ _external_: ChoiceAlternativeList
  706. // ChoiceDefinition
  707. CARBON_PARSE_NODE_KIND_CHILD_COUNT(ChoiceIntroducer, 0, Choice)
  708. CARBON_PARSE_NODE_KIND_BRACKET(ChoiceDefinitionStart, ChoiceIntroducer,
  709. CARBON_IF_VALID(OpenCurlyBrace))
  710. CARBON_PARSE_NODE_KIND_BRACKET(ChoiceDefinition, ChoiceDefinitionStart,
  711. CARBON_IF_VALID(CloseCurlyBrace))
  712. // Choice alternative list:
  713. // _external_: IdentifierName
  714. // _optional_ _external_ : TuplePattern
  715. // _optional_: ChoiceAlternativeListComma
  716. // _repeated_
  717. // ChoiceAlternativeList
  718. CARBON_PARSE_NODE_KIND_CHILD_COUNT(ChoiceAlternativeListComma, 0, Comma)
  719. // `match`:
  720. // MatchIntroducer
  721. // MatchConditionStart
  722. // _external_: expression
  723. // MatchCondition
  724. // MatchStatementStart
  725. // _repeated_ _external_: MatchCase
  726. // _optional_ _external_: MatchStatementDefault
  727. // MatchStatement
  728. CARBON_PARSE_NODE_KIND_CHILD_COUNT(MatchIntroducer, 0, Match)
  729. CARBON_PARSE_NODE_KIND_CHILD_COUNT(MatchConditionStart, 0,
  730. CARBON_IF_VALID(OpenParen))
  731. CARBON_PARSE_NODE_KIND_BRACKET(MatchCondition, MatchConditionStart,
  732. CARBON_IF_VALID(CloseParen))
  733. CARBON_PARSE_NODE_KIND_BRACKET(MatchStatementStart, MatchIntroducer,
  734. CARBON_IF_VALID(OpenCurlyBrace))
  735. CARBON_PARSE_NODE_KIND_BRACKET(MatchStatement, MatchStatementStart,
  736. CARBON_IF_VALID(CloseCurlyBrace))
  737. // `case`:
  738. // MatchCaseIntroducer
  739. // _external_: Pattern
  740. // MatchCaseGuardIntroducer
  741. // MatchCaseGuardStart
  742. // _external_: expression
  743. // MatchCaseGuard
  744. // MatchCaseEqualGreater
  745. // MatchCaseStart
  746. // _repeated_ _external_: statement
  747. // MatchCase
  748. CARBON_PARSE_NODE_KIND_CHILD_COUNT(MatchCaseIntroducer, 0, Case)
  749. CARBON_PARSE_NODE_KIND_CHILD_COUNT(MatchCaseGuardIntroducer, 0, If)
  750. CARBON_PARSE_NODE_KIND_CHILD_COUNT(MatchCaseGuardStart, 0,
  751. CARBON_IF_VALID(OpenParen))
  752. CARBON_PARSE_NODE_KIND_BRACKET(MatchCaseGuard, MatchCaseGuardIntroducer,
  753. CARBON_IF_VALID(CloseParen))
  754. CARBON_PARSE_NODE_KIND_CHILD_COUNT(MatchCaseEqualGreater, 0,
  755. CARBON_IF_VALID(EqualGreater))
  756. CARBON_PARSE_NODE_KIND_BRACKET(MatchCaseStart, MatchCaseIntroducer,
  757. CARBON_IF_VALID(OpenCurlyBrace))
  758. CARBON_PARSE_NODE_KIND_BRACKET(MatchCase, MatchCaseStart,
  759. CARBON_IF_VALID(CloseCurlyBrace))
  760. // `default`:
  761. // MatchDefaultIntroducer
  762. // MatchDefaultEqualGreater
  763. // MatchDefaultStart
  764. // _repeated_ _external_: statement
  765. // MatchDefault
  766. CARBON_PARSE_NODE_KIND_CHILD_COUNT(MatchDefaultIntroducer, 0, Default)
  767. CARBON_PARSE_NODE_KIND_CHILD_COUNT(MatchDefaultEqualGreater, 0,
  768. CARBON_IF_VALID(EqualGreater))
  769. CARBON_PARSE_NODE_KIND_BRACKET(MatchDefaultStart, MatchDefaultIntroducer,
  770. CARBON_IF_VALID(OpenCurlyBrace))
  771. CARBON_PARSE_NODE_KIND_BRACKET(MatchDefault, MatchDefaultStart,
  772. CARBON_IF_VALID(CloseCurlyBrace))
  773. #undef CARBON_PARSE_NODE_KIND
  774. #undef CARBON_PARSE_NODE_KIND_BRACKET
  775. #undef CARBON_PARSE_NODE_KIND_CHILD_COUNT
  776. #undef CARBON_PARSE_NODE_KIND_INFIX_OPERATOR
  777. #undef CARBON_PARSE_NODE_KIND_POSTFIX_OPERATOR
  778. #undef CARBON_PARSE_NODE_KIND_PREFIX_OPERATOR
  779. #undef CARBON_PARSE_NODE_KIND_TOKEN_LITERAL
  780. #undef CARBON_PARSE_NODE_KIND_TOKEN_MODIFIER
  781. #undef CARBON_IF_VALID