@@ -81,7 +81,7 @@ macro some_macro {
81
81
│ │ │ │ │ └── ident (kind: TokenIdentifier): 'ident'
82
82
│ │ │ │ ├── child #5 (kind: TokenTreeLeaf)
83
83
│ │ │ │ │ └── leaf (kind: TokenPlus): '+'
84
- │ │ │ │ └── child #6 (kind: MacroMatcherwrapper )
84
+ │ │ │ │ └── child #6 (kind: MacroMatcherWrapper )
85
85
│ │ │ │ └── subtree (kind: ParenthesizedMacroMatcher)
86
86
│ │ │ │ ├── lparen (kind: TokenLParen): '('
87
87
│ │ │ │ ├── elements (kind: MacroRuleElements)
@@ -93,7 +93,7 @@ macro some_macro {
93
93
│ │ │ │ │ │ └── ident (kind: TokenIdentifier): 'ident'
94
94
│ │ │ │ │ ├── child #1 (kind: TokenTreeLeaf)
95
95
│ │ │ │ │ │ └── leaf (kind: TokenPlus): '+'
96
- │ │ │ │ │ └── child #2 (kind: MacroMatcherwrapper )
96
+ │ │ │ │ │ └── child #2 (kind: MacroMatcherWrapper )
97
97
│ │ │ │ │ └── subtree (kind: ParenthesizedMacroMatcher)
98
98
│ │ │ │ │ ├── lparen (kind: TokenLParen): '('
99
99
│ │ │ │ │ ├── elements (kind: MacroRuleElements)
@@ -118,3 +118,155 @@ macro some_macro {
118
118
│ │ └── semicolon (kind: TokenSemicolon): ';'
119
119
│ └── rbrace (kind: TokenRBrace): '}'
120
120
└── eof (kind: TokenEndOfFile).
121
+
122
+ //! > ==========================================================================
123
+
124
+ //! > Test a syntax tree with optional repetitions
125
+
126
+ //! > test_runner_name
127
+ test_partial_parser_tree(expect_diagnostics: false)
128
+
129
+ //! > cairo_code
130
+ macro some_macro {
131
+ ($x:ident $y:ident? $z:expr?) => {
132
+ 1
133
+ };
134
+ }
135
+
136
+ fn use_macro() {
137
+ some_macro!(foo);
138
+ some_macro!(foo bar);
139
+ some_macro!(foo bar 100);
140
+ }
141
+
142
+ //! > top_level_kind
143
+
144
+ //! > ignored_kinds
145
+
146
+ //! > expected_diagnostics
147
+
148
+ //! > expected_tree
149
+ └── root (kind: SyntaxFile)
150
+ ├── items (kind: ModuleItemList)
151
+ │ ├── child #0 (kind: ItemMacroDeclaration)
152
+ │ │ ├── attributes (kind: AttributeList) []
153
+ │ │ ├── visibility (kind: VisibilityDefault) []
154
+ │ │ ├── macro_kw (kind: TokenMacro): 'macro'
155
+ │ │ ├── name (kind: TokenIdentifier): 'some_macro'
156
+ │ │ ├── lbrace (kind: TokenLBrace): '{'
157
+ │ │ ├── rules (kind: MacroRulesList)
158
+ │ │ │ └── child #0 (kind: MacroRule)
159
+ │ │ │ ├── lhs (kind: ParenthesizedMacroMatcher)
160
+ │ │ │ │ ├── lparen (kind: TokenLParen): '('
161
+ │ │ │ │ ├── elements (kind: MacroRuleElements)
162
+ │ │ │ │ │ ├── child #0 (kind: MacroRuleParam)
163
+ │ │ │ │ │ │ ├── dollar (kind: TokenDollar): '$'
164
+ │ │ │ │ │ │ ├── name (kind: TokenIdentifier): 'x'
165
+ │ │ │ │ │ │ ├── colon (kind: TokenColon): ':'
166
+ │ │ │ │ │ │ └── kind (kind: ParamIdent)
167
+ │ │ │ │ │ │ └── ident (kind: TokenIdentifier): 'ident'
168
+ │ │ │ │ │ ├── child #1 (kind: MacroRuleParam)
169
+ │ │ │ │ │ │ ├── dollar (kind: TokenDollar): '$'
170
+ │ │ │ │ │ │ ├── name (kind: TokenIdentifier): 'y'
171
+ │ │ │ │ │ │ ├── colon (kind: TokenColon): ':'
172
+ │ │ │ │ │ │ └── kind (kind: ParamIdent)
173
+ │ │ │ │ │ │ └── ident (kind: TokenIdentifier): 'ident'
174
+ │ │ │ │ │ ├── child #2 (kind: TokenTreeLeaf)
175
+ │ │ │ │ │ │ └── leaf (kind: TokenQuestionMark): '?'
176
+ │ │ │ │ │ ├── child #3 (kind: MacroRuleParam)
177
+ │ │ │ │ │ │ ├── dollar (kind: TokenDollar): '$'
178
+ │ │ │ │ │ │ ├── name (kind: TokenIdentifier): 'z'
179
+ │ │ │ │ │ │ ├── colon (kind: TokenColon): ':'
180
+ │ │ │ │ │ │ └── kind (kind: ParamExpr)
181
+ │ │ │ │ │ │ └── expr (kind: TokenIdentifier): 'expr'
182
+ │ │ │ │ │ └── child #4 (kind: TokenTreeLeaf)
183
+ │ │ │ │ │ └── leaf (kind: TokenQuestionMark): '?'
184
+ │ │ │ │ └── rparen (kind: TokenRParen): ')'
185
+ │ │ │ ├── fat_arrow (kind: TokenMatchArrow): '=>'
186
+ │ │ │ ├── rhs (kind: ExprBlock)
187
+ │ │ │ │ ├── lbrace (kind: TokenLBrace): '{'
188
+ │ │ │ │ ├── statements (kind: StatementList)
189
+ │ │ │ │ │ └── child #0 (kind: StatementExpr)
190
+ │ │ │ │ │ ├── attributes (kind: AttributeList) []
191
+ │ │ │ │ │ ├── expr (kind: TokenLiteralNumber): '1'
192
+ │ │ │ │ │ └── semicolon (kind: OptionTerminalSemicolonEmpty) []
193
+ │ │ │ │ └── rbrace (kind: TokenRBrace): '}'
194
+ │ │ │ └── semicolon (kind: TokenSemicolon): ';'
195
+ │ │ └── rbrace (kind: TokenRBrace): '}'
196
+ │ └── child #1 (kind: FunctionWithBody)
197
+ │ ├── attributes (kind: AttributeList) []
198
+ │ ├── visibility (kind: VisibilityDefault) []
199
+ │ ├── declaration (kind: FunctionDeclaration)
200
+ │ │ ├── optional_const (kind: OptionTerminalConstEmpty) []
201
+ │ │ ├── function_kw (kind: TokenFunction): 'fn'
202
+ │ │ ├── name (kind: TokenIdentifier): 'use_macro'
203
+ │ │ ├── generic_params (kind: OptionWrappedGenericParamListEmpty) []
204
+ │ │ └── signature (kind: FunctionSignature)
205
+ │ │ ├── lparen (kind: TokenLParen): '('
206
+ │ │ ├── parameters (kind: ParamList) []
207
+ │ │ ├── rparen (kind: TokenRParen): ')'
208
+ │ │ ├── ret_ty (kind: OptionReturnTypeClauseEmpty) []
209
+ │ │ ├── implicits_clause (kind: OptionImplicitsClauseEmpty) []
210
+ │ │ └── optional_no_panic (kind: OptionTerminalNoPanicEmpty) []
211
+ │ └── body (kind: ExprBlock)
212
+ │ ├── lbrace (kind: TokenLBrace): '{'
213
+ │ ├── statements (kind: StatementList)
214
+ │ │ ├── child #0 (kind: StatementExpr)
215
+ │ │ │ ├── attributes (kind: AttributeList) []
216
+ │ │ │ ├── expr (kind: ExprInlineMacro)
217
+ │ │ │ │ ├── path (kind: ExprPath)
218
+ │ │ │ │ │ ├── dollar (kind: OptionTerminalDollarEmpty) []
219
+ │ │ │ │ │ └── segments (kind: ExprPathInner)
220
+ │ │ │ │ │ └── item #0 (kind: PathSegmentSimple)
221
+ │ │ │ │ │ └── ident (kind: TokenIdentifier): 'some_macro'
222
+ │ │ │ │ ├── bang (kind: TokenNot): '!'
223
+ │ │ │ │ └── arguments (kind: TokenTreeNode)
224
+ │ │ │ │ └── subtree (kind: ParenthesizedTokenTree)
225
+ │ │ │ │ ├── lparen (kind: TokenLParen): '('
226
+ │ │ │ │ ├── tokens (kind: TokenList)
227
+ │ │ │ │ │ └── child #0 (kind: TokenTreeLeaf)
228
+ │ │ │ │ │ └── leaf (kind: TokenIdentifier): 'foo'
229
+ │ │ │ │ └── rparen (kind: TokenRParen): ')'
230
+ │ │ │ └── semicolon (kind: TokenSemicolon): ';'
231
+ │ │ ├── child #1 (kind: StatementExpr)
232
+ │ │ │ ├── attributes (kind: AttributeList) []
233
+ │ │ │ ├── expr (kind: ExprInlineMacro)
234
+ │ │ │ │ ├── path (kind: ExprPath)
235
+ │ │ │ │ │ ├── dollar (kind: OptionTerminalDollarEmpty) []
236
+ │ │ │ │ │ └── segments (kind: ExprPathInner)
237
+ │ │ │ │ │ └── item #0 (kind: PathSegmentSimple)
238
+ │ │ │ │ │ └── ident (kind: TokenIdentifier): 'some_macro'
239
+ │ │ │ │ ├── bang (kind: TokenNot): '!'
240
+ │ │ │ │ └── arguments (kind: TokenTreeNode)
241
+ │ │ │ │ └── subtree (kind: ParenthesizedTokenTree)
242
+ │ │ │ │ ├── lparen (kind: TokenLParen): '('
243
+ │ │ │ │ ├── tokens (kind: TokenList)
244
+ │ │ │ │ │ ├── child #0 (kind: TokenTreeLeaf)
245
+ │ │ │ │ │ │ └── leaf (kind: TokenIdentifier): 'foo'
246
+ │ │ │ │ │ └── child #1 (kind: TokenTreeLeaf)
247
+ │ │ │ │ │ └── leaf (kind: TokenIdentifier): 'bar'
248
+ │ │ │ │ └── rparen (kind: TokenRParen): ')'
249
+ │ │ │ └── semicolon (kind: TokenSemicolon): ';'
250
+ │ │ └── child #2 (kind: StatementExpr)
251
+ │ │ ├── attributes (kind: AttributeList) []
252
+ │ │ ├── expr (kind: ExprInlineMacro)
253
+ │ │ │ ├── path (kind: ExprPath)
254
+ │ │ │ │ ├── dollar (kind: OptionTerminalDollarEmpty) []
255
+ │ │ │ │ └── segments (kind: ExprPathInner)
256
+ │ │ │ │ └── item #0 (kind: PathSegmentSimple)
257
+ │ │ │ │ └── ident (kind: TokenIdentifier): 'some_macro'
258
+ │ │ │ ├── bang (kind: TokenNot): '!'
259
+ │ │ │ └── arguments (kind: TokenTreeNode)
260
+ │ │ │ └── subtree (kind: ParenthesizedTokenTree)
261
+ │ │ │ ├── lparen (kind: TokenLParen): '('
262
+ │ │ │ ├── tokens (kind: TokenList)
263
+ │ │ │ │ ├── child #0 (kind: TokenTreeLeaf)
264
+ │ │ │ │ │ └── leaf (kind: TokenIdentifier): 'foo'
265
+ │ │ │ │ ├── child #1 (kind: TokenTreeLeaf)
266
+ │ │ │ │ │ └── leaf (kind: TokenIdentifier): 'bar'
267
+ │ │ │ │ └── child #2 (kind: TokenTreeLeaf)
268
+ │ │ │ │ └── leaf (kind: TokenLiteralNumber): '100'
269
+ │ │ │ └── rparen (kind: TokenRParen): ')'
270
+ │ │ └── semicolon (kind: TokenSemicolon): ';'
271
+ │ └── rbrace (kind: TokenRBrace): '}'
272
+ └── eof (kind: TokenEndOfFile).
0 commit comments