@@ -266,3 +266,135 @@ error: Missing tokens. Expected a macro rule parameter kind.
266
266
│ │ └── semicolon (kind: TokenSemicolon): ';'
267
267
│ └── rbrace (kind: TokenRBrace): '}'
268
268
└── eof (kind: TokenEndOfFile).
269
+
270
+ //! > ==========================================================================
271
+
272
+ //! > Test macro statement expansion.
273
+
274
+ //! > test_runner_name
275
+ test_partial_parser_tree(expect_diagnostics: false)
276
+
277
+ //! > cairo_code
278
+ macro array_macro2 {
279
+ ($($x:expr), *) => {
280
+ let mut arr = ArrayTrait::new();
281
+ $(
282
+ arr.append($x);
283
+ ), *
284
+ arr
285
+ };
286
+ }
287
+
288
+ //! > top_level_kind
289
+
290
+ //! > ignored_kinds
291
+
292
+ //! > expected_diagnostics^
293
+
294
+ //! > expected_tree
295
+ └── root (kind: SyntaxFile)
296
+ ├── items (kind: ModuleItemList)
297
+ │ └── child #0 (kind: ItemMacroDeclaration)
298
+ │ ├── attributes (kind: AttributeList) []
299
+ │ ├── visibility (kind: VisibilityDefault) []
300
+ │ ├── macro_kw (kind: TokenMacro): 'macro'
301
+ │ ├── name (kind: TokenIdentifier): 'array_macro2'
302
+ │ ├── lbrace (kind: TokenLBrace): '{'
303
+ │ ├── rules (kind: MacroRulesList)
304
+ │ │ └── child #0 (kind: MacroRule)
305
+ │ │ ├── lhs (kind: ParenthesizedMacroMatcher)
306
+ │ │ │ ├── lparen (kind: TokenLParen): '('
307
+ │ │ │ ├── elements (kind: MacroRuleElements)
308
+ │ │ │ │ └── child #0 (kind: MacroRepetition)
309
+ │ │ │ │ ├── dollar (kind: TokenDollar): '$'
310
+ │ │ │ │ ├── lparen (kind: TokenLParen): '('
311
+ │ │ │ │ ├── elements (kind: MacroRuleElements)
312
+ │ │ │ │ │ └── child #0 (kind: MacroRuleParam)
313
+ │ │ │ │ │ ├── dollar (kind: TokenDollar): '$'
314
+ │ │ │ │ │ ├── name (kind: TokenIdentifier): 'x'
315
+ │ │ │ │ │ ├── colon (kind: TokenColon): ':'
316
+ │ │ │ │ │ └── kind (kind: ParamExpr)
317
+ │ │ │ │ │ └── expr (kind: TokenIdentifier): 'expr'
318
+ │ │ │ │ ├── rparen (kind: TokenRParen): ')'
319
+ │ │ │ │ ├── separator (kind: TokenComma): ','
320
+ │ │ │ │ └── operator (kind: TokenMul): '*'
321
+ │ │ │ └── rparen (kind: TokenRParen): ')'
322
+ │ │ ├── fat_arrow (kind: TokenMatchArrow): '=>'
323
+ │ │ ├── rhs (kind: ExprBlock)
324
+ │ │ │ ├── lbrace (kind: TokenLBrace): '{'
325
+ │ │ │ ├── statements (kind: StatementList)
326
+ │ │ │ │ ├── child #0 (kind: StatementLet)
327
+ │ │ │ │ │ ├── attributes (kind: AttributeList) []
328
+ │ │ │ │ │ ├── let_kw (kind: TokenLet): 'let'
329
+ │ │ │ │ │ ├── pattern (kind: PatternIdentifier)
330
+ │ │ │ │ │ │ ├── modifiers (kind: ModifierList)
331
+ │ │ │ │ │ │ │ └── child #0 (kind: TokenMut): 'mut'
332
+ │ │ │ │ │ │ └── name (kind: TokenIdentifier): 'arr'
333
+ │ │ │ │ │ ├── type_clause (kind: OptionTypeClauseEmpty) []
334
+ │ │ │ │ │ ├── eq (kind: TokenEq): '='
335
+ │ │ │ │ │ ├── rhs (kind: ExprFunctionCall)
336
+ │ │ │ │ │ │ ├── path (kind: ExprPath)
337
+ │ │ │ │ │ │ │ ├── dollar (kind: OptionTerminalDollarEmpty) []
338
+ │ │ │ │ │ │ │ └── segments (kind: ExprPathInner)
339
+ │ │ │ │ │ │ │ ├── item #0 (kind: PathSegmentSimple)
340
+ │ │ │ │ │ │ │ │ └── ident (kind: TokenIdentifier): 'ArrayTrait'
341
+ │ │ │ │ │ │ │ ├── separator #0 (kind: TokenColonColon): '::'
342
+ │ │ │ │ │ │ │ └── item #1 (kind: PathSegmentSimple)
343
+ │ │ │ │ │ │ │ └── ident (kind: TokenIdentifier): 'new'
344
+ │ │ │ │ │ │ └── arguments (kind: ArgListParenthesized)
345
+ │ │ │ │ │ │ ├── lparen (kind: TokenLParen): '('
346
+ │ │ │ │ │ │ ├── arguments (kind: ArgList) []
347
+ │ │ │ │ │ │ └── rparen (kind: TokenRParen): ')'
348
+ │ │ │ │ │ └── semicolon (kind: TokenSemicolon): ';'
349
+ │ │ │ │ ├── child #1 (kind: StatementExpr)
350
+ │ │ │ │ │ ├── attributes (kind: AttributeList) []
351
+ │ │ │ │ │ ├── expr (kind: ExprPlaceholderRepetitionBlock)
352
+ │ │ │ │ │ │ ├── dollar (kind: TokenDollar): '$'
353
+ │ │ │ │ │ │ ├── lparen (kind: TokenLParen): '('
354
+ │ │ │ │ │ │ ├── elements (kind: StatementList)
355
+ │ │ │ │ │ │ │ └── child #0 (kind: StatementExpr)
356
+ │ │ │ │ │ │ │ ├── attributes (kind: AttributeList) []
357
+ │ │ │ │ │ │ │ ├── expr (kind: ExprBinary)
358
+ │ │ │ │ │ │ │ │ ├── lhs (kind: ExprPath)
359
+ │ │ │ │ │ │ │ │ │ ├── dollar (kind: OptionTerminalDollarEmpty) []
360
+ │ │ │ │ │ │ │ │ │ └── segments (kind: ExprPathInner)
361
+ │ │ │ │ │ │ │ │ │ └── item #0 (kind: PathSegmentSimple)
362
+ │ │ │ │ │ │ │ │ │ └── ident (kind: TokenIdentifier): 'arr'
363
+ │ │ │ │ │ │ │ │ ├── op (kind: TokenDot): '.'
364
+ │ │ │ │ │ │ │ │ └── rhs (kind: ExprFunctionCall)
365
+ │ │ │ │ │ │ │ │ ├── path (kind: ExprPath)
366
+ │ │ │ │ │ │ │ │ │ ├── dollar (kind: OptionTerminalDollarEmpty) []
367
+ │ │ │ │ │ │ │ │ │ └── segments (kind: ExprPathInner)
368
+ │ │ │ │ │ │ │ │ │ └── item #0 (kind: PathSegmentSimple)
369
+ │ │ │ │ │ │ │ │ │ └── ident (kind: TokenIdentifier): 'append'
370
+ │ │ │ │ │ │ │ │ └── arguments (kind: ArgListParenthesized)
371
+ │ │ │ │ │ │ │ │ ├── lparen (kind: TokenLParen): '('
372
+ │ │ │ │ │ │ │ │ ├── arguments (kind: ArgList)
373
+ │ │ │ │ │ │ │ │ │ └── item #0 (kind: Arg)
374
+ │ │ │ │ │ │ │ │ │ ├── modifiers (kind: ModifierList) []
375
+ │ │ │ │ │ │ │ │ │ └── arg_clause (kind: ArgClauseUnnamed)
376
+ │ │ │ │ │ │ │ │ │ └── value (kind: ExprPath)
377
+ │ │ │ │ │ │ │ │ │ ├── dollar (kind: TokenDollar): '$'
378
+ │ │ │ │ │ │ │ │ │ └── segments (kind: ExprPathInner)
379
+ │ │ │ │ │ │ │ │ │ └── item #0 (kind: PathSegmentSimple)
380
+ │ │ │ │ │ │ │ │ │ └── ident (kind: TokenIdentifier): 'x'
381
+ │ │ │ │ │ │ │ │ └── rparen (kind: TokenRParen): ')'
382
+ │ │ │ │ │ │ │ └── semicolon (kind: TokenSemicolon): ';'
383
+ │ │ │ │ │ │ ├── rparen (kind: TokenRParen): ')'
384
+ │ │ │ │ │ │ ├── separator (kind: TokenComma): ','
385
+ │ │ │ │ │ │ └── operator (kind: TokenMul): '*'
386
+ │ │ │ │ │ └── semicolon (kind: OptionTerminalSemicolonEmpty) []
387
+ │ │ │ │ └── child #2 (kind: StatementExpr)
388
+ │ │ │ │ ├── attributes (kind: AttributeList) []
389
+ │ │ │ │ ├── expr (kind: ExprPath)
390
+ │ │ │ │ │ ├── dollar (kind: OptionTerminalDollarEmpty) []
391
+ │ │ │ │ │ └── segments (kind: ExprPathInner)
392
+ │ │ │ │ │ └── item #0 (kind: PathSegmentSimple)
393
+ │ │ │ │ │ └── ident (kind: TokenIdentifier): 'arr'
394
+ │ │ │ │ └── semicolon (kind: OptionTerminalSemicolonEmpty) []
395
+ │ │ │ └── rbrace (kind: TokenRBrace): '}'
396
+ │ │ └── semicolon (kind: TokenSemicolon): ';'
397
+ │ └── rbrace (kind: TokenRBrace): '}'
398
+ └── eof (kind: TokenEndOfFile).
399
+
400
+ //! > expected_diagnostics
0 commit comments