aboutsummaryrefslogtreecommitdiff
path: root/xtask/src/ast_src.rs
diff options
context:
space:
mode:
Diffstat (limited to 'xtask/src/ast_src.rs')
-rw-r--r--xtask/src/ast_src.rs424
1 files changed, 183 insertions, 241 deletions
diff --git a/xtask/src/ast_src.rs b/xtask/src/ast_src.rs
index eba66ff4d..69cba9168 100644
--- a/xtask/src/ast_src.rs
+++ b/xtask/src/ast_src.rs
@@ -11,7 +11,7 @@ pub(crate) struct KindsSrc<'a> {
11 11
12pub(crate) const KINDS_SRC: KindsSrc = KindsSrc { 12pub(crate) const KINDS_SRC: KindsSrc = KindsSrc {
13 punct: &[ 13 punct: &[
14 (";", "SEMI"), 14 (";", "SEMICOLON"),
15 (",", "COMMA"), 15 (",", "COMMA"),
16 ("(", "L_PAREN"), 16 ("(", "L_PAREN"),
17 (")", "R_PAREN"), 17 (")", "R_PAREN"),
@@ -35,15 +35,15 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc {
35 ("%", "PERCENT"), 35 ("%", "PERCENT"),
36 ("_", "UNDERSCORE"), 36 ("_", "UNDERSCORE"),
37 (".", "DOT"), 37 (".", "DOT"),
38 ("..", "DOTDOT"), 38 ("..", "DOT2"),
39 ("...", "DOTDOTDOT"), 39 ("...", "DOT3"),
40 ("..=", "DOTDOTEQ"), 40 ("..=", "DOT2EQ"),
41 (":", "COLON"), 41 (":", "COLON"),
42 ("::", "COLONCOLON"), 42 ("::", "COLON2"),
43 ("=", "EQ"), 43 ("=", "EQ"),
44 ("==", "EQEQ"), 44 ("==", "EQ2"),
45 ("=>", "FAT_ARROW"), 45 ("=>", "FAT_ARROW"),
46 ("!", "EXCL"), 46 ("!", "BANG"),
47 ("!=", "NEQ"), 47 ("!=", "NEQ"),
48 ("-", "MINUS"), 48 ("-", "MINUS"),
49 ("->", "THIN_ARROW"), 49 ("->", "THIN_ARROW"),
@@ -57,8 +57,8 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc {
57 ("/=", "SLASHEQ"), 57 ("/=", "SLASHEQ"),
58 ("*=", "STAREQ"), 58 ("*=", "STAREQ"),
59 ("%=", "PERCENTEQ"), 59 ("%=", "PERCENTEQ"),
60 ("&&", "AMPAMP"), 60 ("&&", "AMP2"),
61 ("||", "PIPEPIPE"), 61 ("||", "PIPE2"),
62 ("<<", "SHL"), 62 ("<<", "SHL"),
63 (">>", "SHR"), 63 (">>", "SHR"),
64 ("<<=", "SHLEQ"), 64 ("<<=", "SHLEQ"),
@@ -225,21 +225,26 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc {
225}; 225};
226 226
227pub(crate) struct AstSrc<'a> { 227pub(crate) struct AstSrc<'a> {
228 pub(crate) tokens: &'a [&'a str],
228 pub(crate) nodes: &'a [AstNodeSrc<'a>], 229 pub(crate) nodes: &'a [AstNodeSrc<'a>],
229 pub(crate) enums: &'a [AstEnumSrc<'a>], 230 pub(crate) enums: &'a [AstEnumSrc<'a>],
230 pub(crate) token_enums: &'a [AstEnumSrc<'a>],
231} 231}
232 232
233pub(crate) struct AstNodeSrc<'a> { 233pub(crate) struct AstNodeSrc<'a> {
234 pub(crate) name: &'a str, 234 pub(crate) name: &'a str,
235 pub(crate) traits: &'a [&'a str], 235 pub(crate) traits: &'a [&'a str],
236 pub(crate) fields: &'a [(&'a str, FieldSrc<&'a str>)], 236 pub(crate) fields: &'a [Field<'a>],
237}
238
239pub(crate) enum Field<'a> {
240 Token(&'a str),
241 Node { name: &'a str, src: FieldSrc<'a> },
237} 242}
238 243
239pub(crate) enum FieldSrc<T> { 244pub(crate) enum FieldSrc<'a> {
240 Shorthand, 245 Shorthand,
241 Optional(T), 246 Optional(&'a str),
242 Many(T), 247 Many(&'a str),
243} 248}
244 249
245pub(crate) struct AstEnumSrc<'a> { 250pub(crate) struct AstEnumSrc<'a> {
@@ -251,31 +256,34 @@ pub(crate) struct AstEnumSrc<'a> {
251macro_rules! ast_nodes { 256macro_rules! ast_nodes {
252 ($( 257 ($(
253 struct $name:ident$(: $($trait:ident),*)? { 258 struct $name:ident$(: $($trait:ident),*)? {
254 $($field_name:ident $(: $ty:tt)?),*$(,)? 259 $($field_name:ident $(![$token:tt])? $(: $ty:tt)?),*$(,)?
255 } 260 }
256 )*) => { 261 )*) => {
257 [$( 262 [$(
258 AstNodeSrc { 263 AstNodeSrc {
259 name: stringify!($name), 264 name: stringify!($name),
260 traits: &[$($(stringify!($trait)),*)?], 265 traits: &[$($(stringify!($trait)),*)?],
261 fields: &[$( 266 fields: &[
262 (stringify!($field_name), field_ty!($field_name $($ty)?)) 267 $(field!($(T![$token])? $field_name $($ty)?)),*
263 ),*], 268 ],
264 269
265 } 270 }
266 ),*] 271 ),*]
267 }; 272 };
268} 273}
269 274
270macro_rules! field_ty { 275macro_rules! field {
276 (T![$token:tt] T) => {
277 Field::Token(stringify!($token))
278 };
271 ($field_name:ident) => { 279 ($field_name:ident) => {
272 FieldSrc::Shorthand 280 Field::Node { name: stringify!($field_name), src: FieldSrc::Shorthand }
273 }; 281 };
274 ($field_name:ident [$ty:ident]) => { 282 ($field_name:ident [$ty:ident]) => {
275 FieldSrc::Many(stringify!($ty)) 283 Field::Node { name: stringify!($field_name), src: FieldSrc::Many(stringify!($ty)) }
276 }; 284 };
277 ($field_name:ident $ty:ident) => { 285 ($field_name:ident $ty:ident) => {
278 FieldSrc::Optional(stringify!($ty)) 286 Field::Node { name: stringify!($field_name), src: FieldSrc::Optional(stringify!($ty)) }
279 }; 287 };
280} 288}
281 289
@@ -290,330 +298,331 @@ macro_rules! ast_enums {
290 name: stringify!($name), 298 name: stringify!($name),
291 traits: &[$($(stringify!($trait)),*)?], 299 traits: &[$($(stringify!($trait)),*)?],
292 variants: &[$(stringify!($variant)),*], 300 variants: &[$(stringify!($variant)),*],
293
294 } 301 }
295 ),*] 302 ),*]
296 }; 303 };
297} 304}
298 305
299pub(crate) const AST_SRC: AstSrc = AstSrc { 306pub(crate) const AST_SRC: AstSrc = AstSrc {
307 tokens: &["Whitespace", "Comment", "String", "RawString"],
300 nodes: &ast_nodes! { 308 nodes: &ast_nodes! {
301 struct SourceFile: ModuleItemOwner, FnDefOwner, AttrsOwner { 309 struct SourceFile: ModuleItemOwner, AttrsOwner {
302 modules: [Module], 310 modules: [Module],
303 } 311 }
304 312
305 struct FnDef: VisibilityOwner, NameOwner, TypeParamsOwner, DocCommentsOwner, AttrsOwner { 313 struct FnDef: VisibilityOwner, NameOwner, TypeParamsOwner, DocCommentsOwner, AttrsOwner {
306 Abi, 314 Abi,
307 ConstKw, 315 T![const],
308 DefaultKw, 316 T![default],
309 AsyncKw, 317 T![async],
310 UnsafeKw, 318 T![unsafe],
311 FnKw, 319 T![fn],
312 ParamList, 320 ParamList,
313 RetType, 321 RetType,
314 body: BlockExpr, 322 body: BlockExpr,
315 Semi 323 T![;]
316 } 324 }
317 325
318 struct RetType { ThinArrow, TypeRef } 326 struct RetType { T![->], TypeRef }
319 327
320 struct StructDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner { 328 struct StructDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner {
321 StructKw, 329 T![struct],
322 FieldDefList, 330 FieldDefList,
323 Semi 331 T![;]
324 } 332 }
325 333
326 struct UnionDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner { 334 struct UnionDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner {
327 UnionKw, 335 T![union],
328 RecordFieldDefList, 336 RecordFieldDefList,
329 } 337 }
330 338
331 struct RecordFieldDefList { LCurly, fields: [RecordFieldDef], RCurly } 339 struct RecordFieldDefList { T!['{'], fields: [RecordFieldDef], T!['}'] }
332 struct RecordFieldDef: VisibilityOwner, NameOwner, AttrsOwner, DocCommentsOwner, TypeAscriptionOwner { } 340 struct RecordFieldDef: VisibilityOwner, NameOwner, AttrsOwner, DocCommentsOwner, TypeAscriptionOwner { }
333 341
334 struct TupleFieldDefList { LParen, fields: [TupleFieldDef], RParen } 342 struct TupleFieldDefList { T!['('], fields: [TupleFieldDef], T![')'] }
335 struct TupleFieldDef: VisibilityOwner, AttrsOwner { 343 struct TupleFieldDef: VisibilityOwner, AttrsOwner {
336 TypeRef, 344 TypeRef,
337 } 345 }
338 346
339 struct EnumDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner { 347 struct EnumDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner {
340 EnumKw, 348 T![enum],
341 variant_list: EnumVariantList, 349 variant_list: EnumVariantList,
342 } 350 }
343 struct EnumVariantList { 351 struct EnumVariantList {
344 LCurly, 352 T!['{'],
345 variants: [EnumVariant], 353 variants: [EnumVariant],
346 RCurly 354 T!['}']
347 } 355 }
348 struct EnumVariant: VisibilityOwner, NameOwner, DocCommentsOwner, AttrsOwner { 356 struct EnumVariant: VisibilityOwner, NameOwner, DocCommentsOwner, AttrsOwner {
349 FieldDefList, 357 FieldDefList,
350 Eq, 358 T![=],
351 Expr 359 Expr
352 } 360 }
353 361
354 struct TraitDef: VisibilityOwner, NameOwner, AttrsOwner, DocCommentsOwner, TypeParamsOwner, TypeBoundsOwner { 362 struct TraitDef: VisibilityOwner, NameOwner, AttrsOwner, DocCommentsOwner, TypeParamsOwner, TypeBoundsOwner {
355 UnsafeKw, 363 T![unsafe],
356 AutoKw, 364 T![auto],
357 TraitKw, 365 T![trait],
358 ItemList, 366 ItemList,
359 } 367 }
360 368
361 struct Module: VisibilityOwner, NameOwner, AttrsOwner, DocCommentsOwner { 369 struct Module: VisibilityOwner, NameOwner, AttrsOwner, DocCommentsOwner {
362 ModKw, 370 T![mod],
363 ItemList, 371 ItemList,
364 Semi 372 T![;]
365 } 373 }
366 374
367 struct ItemList: FnDefOwner, ModuleItemOwner { 375 struct ItemList: ModuleItemOwner {
368 LCurly, 376 T!['{'],
369 impl_items: [ImplItem], 377 impl_items: [ImplItem],
370 RCurly 378 T!['}']
371 } 379 }
372 380
373 struct ConstDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeAscriptionOwner { 381 struct ConstDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeAscriptionOwner {
374 DefaultKw, 382 T![default],
375 ConstKw, 383 T![const],
376 Eq, 384 T![=],
377 body: Expr, 385 body: Expr,
378 Semi 386 T![;]
379 } 387 }
380 388
381 struct StaticDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeAscriptionOwner { 389 struct StaticDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeAscriptionOwner {
382 StaticKw, 390 T![static],
383 MutKw, 391 T![mut],
384 Eq, 392 T![=],
385 body: Expr, 393 body: Expr,
386 Semi 394 T![;]
387 } 395 }
388 396
389 struct TypeAliasDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeBoundsOwner { 397 struct TypeAliasDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeBoundsOwner {
390 DefaultKw, 398 T![default],
391 TypeKw, 399 T![type],
392 Eq, 400 T![=],
393 TypeRef, 401 TypeRef,
394 Semi 402 T![;]
395 } 403 }
396 404
397 struct ImplDef: TypeParamsOwner, AttrsOwner { 405 struct ImplDef: TypeParamsOwner, AttrsOwner {
398 DefaultKw, 406 T![default],
399 ConstKw, 407 T![const],
400 UnsafeKw, 408 T![unsafe],
401 ImplKw, 409 T![impl],
402 Excl, 410 T![!],
403 ForKw, 411 T![for],
404 ItemList, 412 ItemList,
405 } 413 }
406 414
407 struct ParenType { LParen, TypeRef, RParen } 415 struct ParenType { T!['('], TypeRef, T![')'] }
408 struct TupleType { LParen, fields: [TypeRef], RParen } 416 struct TupleType { T!['('], fields: [TypeRef], T![')'] }
409 struct NeverType { Excl } 417 struct NeverType { T![!] }
410 struct PathType { Path } 418 struct PathType { Path }
411 struct PointerType { Star, ConstKw, TypeRef } 419 struct PointerType { T![*], T![const], T![mut], TypeRef }
412 struct ArrayType { LBrack, TypeRef, Semi, Expr, RBrack } 420 struct ArrayType { T!['['], TypeRef, T![;], Expr, T![']'] }
413 struct SliceType { LBrack, TypeRef, RBrack } 421 struct SliceType { T!['['], TypeRef, T![']'] }
414 struct ReferenceType { Amp, Lifetime, MutKw, TypeRef } 422 struct ReferenceType { T![&], T![lifetime], T![mut], TypeRef }
415 struct PlaceholderType { Underscore } 423 struct PlaceholderType { T![_] }
416 struct FnPointerType { Abi, UnsafeKw, FnKw, ParamList, RetType } 424 struct FnPointerType { Abi, T![unsafe], T![fn], ParamList, RetType }
417 struct ForType { ForKw, TypeParamList, TypeRef } 425 struct ForType { T![for], TypeParamList, TypeRef }
418 struct ImplTraitType: TypeBoundsOwner { ImplKw } 426 struct ImplTraitType: TypeBoundsOwner { T![impl] }
419 struct DynTraitType: TypeBoundsOwner { DynKw } 427 struct DynTraitType: TypeBoundsOwner { T![dyn] }
420 428
421 struct TupleExpr: AttrsOwner { LParen, exprs: [Expr], RParen } 429 struct TupleExpr: AttrsOwner { T!['('], exprs: [Expr], T![')'] }
422 struct ArrayExpr: AttrsOwner { LBrack, exprs: [Expr], Semi, RBrack } 430 struct ArrayExpr: AttrsOwner { T!['['], exprs: [Expr], T![;], T![']'] }
423 struct ParenExpr: AttrsOwner { LParen, Expr, RParen } 431 struct ParenExpr: AttrsOwner { T!['('], Expr, T![')'] }
424 struct PathExpr { Path } 432 struct PathExpr { Path }
425 struct LambdaExpr: AttrsOwner { 433 struct LambdaExpr: AttrsOwner {
426 StaticKw, 434 T![static],
427 AsyncKw, 435 T![async],
428 MoveKw, 436 T![move],
429 ParamList, 437 ParamList,
430 RetType, 438 RetType,
431 body: Expr, 439 body: Expr,
432 } 440 }
433 struct IfExpr: AttrsOwner { IfKw, Condition } 441 struct IfExpr: AttrsOwner { T![if], Condition }
434 struct LoopExpr: AttrsOwner, LoopBodyOwner { LoopKw } 442 struct LoopExpr: AttrsOwner, LoopBodyOwner { T![loop] }
435 struct TryBlockExpr: AttrsOwner { TryKw, body: BlockExpr } 443 struct TryBlockExpr: AttrsOwner { T![try], body: BlockExpr }
436 struct ForExpr: AttrsOwner, LoopBodyOwner { 444 struct ForExpr: AttrsOwner, LoopBodyOwner {
437 ForKw, 445 T![for],
438 Pat, 446 Pat,
439 InKw, 447 T![in],
440 iterable: Expr, 448 iterable: Expr,
441 } 449 }
442 struct WhileExpr: AttrsOwner, LoopBodyOwner { WhileKw, Condition } 450 struct WhileExpr: AttrsOwner, LoopBodyOwner { T![while], Condition }
443 struct ContinueExpr: AttrsOwner { ContinueKw, Lifetime } 451 struct ContinueExpr: AttrsOwner { T![continue], T![lifetime] }
444 struct BreakExpr: AttrsOwner { BreakKw, Lifetime, Expr } 452 struct BreakExpr: AttrsOwner { T![break], T![lifetime], Expr }
445 struct Label { Lifetime } 453 struct Label { T![lifetime] }
446 struct BlockExpr: AttrsOwner { Label, UnsafeKw, Block } 454 struct BlockExpr: AttrsOwner { Label, T![unsafe], Block }
447 struct ReturnExpr: AttrsOwner { Expr } 455 struct ReturnExpr: AttrsOwner { Expr }
448 struct CallExpr: ArgListOwner { Expr } 456 struct CallExpr: ArgListOwner { Expr }
449 struct MethodCallExpr: AttrsOwner, ArgListOwner { 457 struct MethodCallExpr: AttrsOwner, ArgListOwner {
450 Expr, Dot, NameRef, TypeArgList, 458 Expr, T![.], NameRef, TypeArgList,
451 } 459 }
452 struct IndexExpr: AttrsOwner { LBrack, RBrack } 460 struct IndexExpr: AttrsOwner { T!['['], T![']'] }
453 struct FieldExpr: AttrsOwner { Expr, Dot, NameRef } 461 struct FieldExpr: AttrsOwner { Expr, T![.], NameRef }
454 struct AwaitExpr: AttrsOwner { Expr, Dot, AwaitKw } 462 struct AwaitExpr: AttrsOwner { Expr, T![.], T![await] }
455 struct TryExpr: AttrsOwner { TryKw, Expr } 463 struct TryExpr: AttrsOwner { T![try], Expr }
456 struct CastExpr: AttrsOwner { Expr, AsKw, TypeRef } 464 struct CastExpr: AttrsOwner { Expr, T![as], TypeRef }
457 struct RefExpr: AttrsOwner { Amp, RawKw, MutKw, Expr } 465 struct RefExpr: AttrsOwner { T![&], T![raw], T![mut], Expr }
458 struct PrefixExpr: AttrsOwner { PrefixOp, Expr } 466 struct PrefixExpr: AttrsOwner { /*PrefixOp,*/ Expr }
459 struct BoxExpr: AttrsOwner { BoxKw, Expr } 467 struct BoxExpr: AttrsOwner { T![box], Expr }
460 struct RangeExpr: AttrsOwner { RangeOp } 468 struct RangeExpr: AttrsOwner { /*RangeOp*/ }
461 struct BinExpr: AttrsOwner { BinOp } 469 struct BinExpr: AttrsOwner { /*BinOp*/ }
462 struct Literal { LiteralToken } 470 struct Literal { /*LiteralToken*/ }
463 471
464 struct MatchExpr: AttrsOwner { MatchKw, Expr, MatchArmList } 472 struct MatchExpr: AttrsOwner { T![match], Expr, MatchArmList }
465 struct MatchArmList: AttrsOwner { LCurly, arms: [MatchArm], RCurly } 473 struct MatchArmList: AttrsOwner { T!['{'], arms: [MatchArm], T!['}'] }
466 struct MatchArm: AttrsOwner { 474 struct MatchArm: AttrsOwner {
467 pat: Pat, 475 pat: Pat,
468 guard: MatchGuard, 476 guard: MatchGuard,
469 FatArrow, 477 T![=>],
470 Expr, 478 Expr,
471 } 479 }
472 struct MatchGuard { IfKw, Expr } 480 struct MatchGuard { T![if], Expr }
473 481
474 struct RecordLit { Path, RecordFieldList} 482 struct RecordLit { Path, RecordFieldList}
475 struct RecordFieldList { 483 struct RecordFieldList {
476 LCurly, 484 T!['{'],
477 fields: [RecordField], 485 fields: [RecordField],
478 Dotdot, 486 T![..],
479 spread: Expr, 487 spread: Expr,
480 RCurly 488 T!['}']
481 } 489 }
482 struct RecordField: AttrsOwner { NameRef, Colon, Expr } 490 struct RecordField: AttrsOwner { NameRef, T![:], Expr }
483 491
484 struct OrPat { pats: [Pat] } 492 struct OrPat { pats: [Pat] }
485 struct ParenPat { LParen, Pat, RParen } 493 struct ParenPat { T!['('], Pat, T![')'] }
486 struct RefPat { Amp, MutKw, Pat } 494 struct RefPat { T![&], T![mut], Pat }
487 struct BoxPat { BoxKw, Pat } 495 struct BoxPat { T![box], Pat }
488 struct BindPat: AttrsOwner, NameOwner { RefKw, MutKw, Pat } 496 struct BindPat: AttrsOwner, NameOwner { T![ref], T![mut], T![@], Pat }
489 struct PlaceholderPat { Underscore } 497 struct PlaceholderPat { T![_] }
490 struct DotDotPat { Dotdot } 498 struct DotDotPat { T![..] }
491 struct PathPat { Path } 499 struct PathPat { Path }
492 struct SlicePat { LBrack, args: [Pat], RBrack } 500 struct SlicePat { T!['['], args: [Pat], T![']'] }
493 struct RangePat { RangeSeparator } 501 struct RangePat { /*RangeSeparator*/ }
494 struct LiteralPat { Literal } 502 struct LiteralPat { Literal }
495 struct MacroPat { MacroCall } 503 struct MacroPat { MacroCall }
496 504
497 struct RecordPat { RecordFieldPatList, Path } 505 struct RecordPat { RecordFieldPatList, Path }
498 struct RecordFieldPatList { 506 struct RecordFieldPatList {
499 LCurly, 507 T!['{'],
500 pats: [RecordInnerPat], 508 pats: [RecordInnerPat],
501 record_field_pats: [RecordFieldPat], 509 record_field_pats: [RecordFieldPat],
502 bind_pats: [BindPat], 510 bind_pats: [BindPat],
503 Dotdot, 511 T![..],
504 RCurly 512 T!['}']
505 } 513 }
506 struct RecordFieldPat: AttrsOwner, NameOwner { Colon, Pat } 514 struct RecordFieldPat: AttrsOwner, NameOwner { T![:], Pat }
507 515
508 struct TupleStructPat { Path, LParen, args: [Pat], RParen } 516 struct TupleStructPat { Path, T!['('], args: [Pat], T![')'] }
509 struct TuplePat { LParen, args: [Pat], RParen } 517 struct TuplePat { T!['('], args: [Pat], T![')'] }
510 518
511 struct Visibility { PubKw, SuperKw, SelfKw, CrateKw } 519 struct Visibility { T![pub], T![super], T![self], T![crate] }
512 struct Name { Ident } 520 struct Name { T![ident] }
513 struct NameRef { NameRefToken } 521 struct NameRef { /*NameRefToken*/ }
514 522
515 struct MacroCall: NameOwner, AttrsOwner,DocCommentsOwner { 523 struct MacroCall: NameOwner, AttrsOwner,DocCommentsOwner {
516 Path, Excl, TokenTree, Semi 524 Path, T![!], TokenTree, T![;]
517 } 525 }
518 struct Attr { Pound, Excl, LBrack, Path, Eq, input: AttrInput, RBrack } 526 struct Attr { T![#], T![!], T!['['], Path, T![=], input: AttrInput, T![']'] }
519 struct TokenTree {} 527 struct TokenTree {}
520 struct TypeParamList { 528 struct TypeParamList {
521 LAngle, 529 T![<],
522 generic_params: [GenericParam], 530 generic_params: [GenericParam],
523 type_params: [TypeParam], 531 type_params: [TypeParam],
524 lifetime_params: [LifetimeParam], 532 lifetime_params: [LifetimeParam],
525 const_params: [ConstParam], 533 const_params: [ConstParam],
526 RAngle 534 T![>]
527 } 535 }
528 struct TypeParam: NameOwner, AttrsOwner, TypeBoundsOwner { 536 struct TypeParam: NameOwner, AttrsOwner, TypeBoundsOwner {
529 Eq, 537 T![=],
530 default_type: TypeRef, 538 default_type: TypeRef,
531 } 539 }
532 struct ConstParam: NameOwner, AttrsOwner, TypeAscriptionOwner { 540 struct ConstParam: NameOwner, AttrsOwner, TypeAscriptionOwner {
533 Eq, 541 T![=],
534 default_val: Expr, 542 default_val: Expr,
535 } 543 }
536 struct LifetimeParam: AttrsOwner { Lifetime} 544 struct LifetimeParam: AttrsOwner { T![lifetime] }
537 struct TypeBound { Lifetime, /* Question, */ ConstKw, /* Question, */ TypeRef} 545 struct TypeBound { T![lifetime], /* Question, */ T![const], /* Question, */ TypeRef}
538 struct TypeBoundList { bounds: [TypeBound] } 546 struct TypeBoundList { bounds: [TypeBound] }
539 struct WherePred: TypeBoundsOwner { Lifetime, TypeRef } 547 struct WherePred: TypeBoundsOwner { T![lifetime], TypeRef }
540 struct WhereClause { WhereKw, predicates: [WherePred] } 548 struct WhereClause { T![where], predicates: [WherePred] }
541 struct Abi { String } 549 struct Abi { /*String*/ }
542 struct ExprStmt: AttrsOwner { Expr, Semi } 550 struct ExprStmt: AttrsOwner { Expr, T![;] }
543 struct LetStmt: AttrsOwner, TypeAscriptionOwner { 551 struct LetStmt: AttrsOwner, TypeAscriptionOwner {
544 LetKw, 552 T![let],
545 Pat, 553 Pat,
546 Eq, 554 T![=],
547 initializer: Expr, 555 initializer: Expr,
556 T![;],
548 } 557 }
549 struct Condition { LetKw, Pat, Eq, Expr } 558 struct Condition { T![let], Pat, T![=], Expr }
550 struct Block: AttrsOwner, ModuleItemOwner { 559 struct Block: AttrsOwner, ModuleItemOwner {
551 LCurly, 560 T!['{'],
552 statements: [Stmt], 561 statements: [Stmt],
553 Expr, 562 Expr,
554 RCurly, 563 T!['}'],
555 } 564 }
556 struct ParamList { 565 struct ParamList {
557 LParen, 566 T!['('],
558 SelfParam, 567 SelfParam,
559 params: [Param], 568 params: [Param],
560 RParen 569 T![')']
561 } 570 }
562 struct SelfParam: TypeAscriptionOwner, AttrsOwner { Amp, Lifetime, SelfKw } 571 struct SelfParam: TypeAscriptionOwner, AttrsOwner { T![&], T![mut], T![lifetime], T![self] }
563 struct Param: TypeAscriptionOwner, AttrsOwner { 572 struct Param: TypeAscriptionOwner, AttrsOwner {
564 Pat, 573 Pat,
565 Dotdotdot 574 T![...]
566 } 575 }
567 struct UseItem: AttrsOwner, VisibilityOwner { 576 struct UseItem: AttrsOwner, VisibilityOwner {
568 UseKw, 577 T![use],
569 UseTree, 578 UseTree,
570 } 579 }
571 struct UseTree { 580 struct UseTree {
572 Path, Star, UseTreeList, Alias 581 Path, T![*], UseTreeList, Alias
573 } 582 }
574 struct Alias: NameOwner { AsKw } 583 struct Alias: NameOwner { T![as] }
575 struct UseTreeList { LCurly, use_trees: [UseTree], RCurly } 584 struct UseTreeList { T!['{'], use_trees: [UseTree], T!['}'] }
576 struct ExternCrateItem: AttrsOwner, VisibilityOwner { 585 struct ExternCrateItem: AttrsOwner, VisibilityOwner {
577 ExternKw, CrateKw, NameRef, Alias, 586 T![extern], T![crate], NameRef, Alias,
578 } 587 }
579 struct ArgList { 588 struct ArgList {
580 LParen, 589 T!['('],
581 args: [Expr], 590 args: [Expr],
582 RParen 591 T![')']
583 } 592 }
584 struct Path { 593 struct Path {
585 segment: PathSegment, 594 segment: PathSegment,
586 qualifier: Path, 595 qualifier: Path,
587 } 596 }
588 struct PathSegment { 597 struct PathSegment {
589 Coloncolon, LAngle, NameRef, TypeArgList, ParamList, RetType, PathType, RAngle 598 T![::], T![<], NameRef, TypeArgList, ParamList, RetType, PathType, T![>]
590 } 599 }
591 struct TypeArgList { 600 struct TypeArgList {
592 Coloncolon, 601 T![::],
593 LAngle, 602 T![<],
594 generic_args: [GenericArg], 603 generic_args: [GenericArg],
595 type_args: [TypeArg], 604 type_args: [TypeArg],
596 lifetime_args: [LifetimeArg], 605 lifetime_args: [LifetimeArg],
597 assoc_type_args: [AssocTypeArg], 606 assoc_type_args: [AssocTypeArg],
598 const_args: [ConstArg], 607 const_args: [ConstArg],
599 RAngle 608 T![>]
600 } 609 }
601 struct TypeArg { TypeRef } 610 struct TypeArg { TypeRef }
602 struct AssocTypeArg : TypeBoundsOwner { NameRef, Eq, TypeRef } 611 struct AssocTypeArg : TypeBoundsOwner { NameRef, T![=], TypeRef }
603 struct LifetimeArg { Lifetime } 612 struct LifetimeArg { T![lifetime] }
604 struct ConstArg { Literal, Eq, BlockExpr } 613 struct ConstArg { Literal, T![=], BlockExpr }
605 614
606 struct MacroItems: ModuleItemOwner, FnDefOwner { } 615 struct MacroItems: ModuleItemOwner{ }
607 616
608 struct MacroStmts { 617 struct MacroStmts {
609 statements: [Stmt], 618 statements: [Stmt],
610 Expr, 619 Expr,
611 } 620 }
612 621
613 struct ExternItemList: FnDefOwner, ModuleItemOwner { 622 struct ExternItemList: ModuleItemOwner {
614 LCurly, 623 T!['{'],
615 extern_items: [ExternItem], 624 extern_items: [ExternItem],
616 RCurly 625 T!['}']
617 } 626 }
618 627
619 struct ExternBlock { 628 struct ExternBlock {
@@ -622,7 +631,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
622 } 631 }
623 632
624 struct MetaItem { 633 struct MetaItem {
625 Path, Eq, AttrInput, nested_meta_items: [MetaItem] 634 Path, T![=], AttrInput, nested_meta_items: [MetaItem]
626 } 635 }
627 636
628 struct MacroDef { 637 struct MacroDef {
@@ -759,71 +768,4 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
759 TupleFieldDefList, 768 TupleFieldDefList,
760 } 769 }
761 }, 770 },
762
763 token_enums: &ast_enums! {
764 enum LeftDelimiter { LParen, LBrack, LCurly }
765 enum RightDelimiter { RParen, RBrack, RCurly }
766 enum RangeSeparator { Dotdot, Dotdotdot, Dotdoteq}
767
768 enum BinOp {
769 Pipepipe,
770 Ampamp,
771 Eqeq,
772 Neq,
773 Lteq,
774 Gteq,
775 LAngle,
776 RAngle,
777 Plus,
778 Star,
779 Minus,
780 Slash,
781 Percent,
782 Shl,
783 Shr,
784 Caret,
785 Pipe,
786 Amp,
787 Eq,
788 Pluseq,
789 Slasheq,
790 Stareq,
791 Percenteq,
792 Shreq,
793 Shleq,
794 Minuseq,
795 Pipeeq,
796 Ampeq,
797 Careteq,
798 }
799
800 enum PrefixOp {
801 Minus,
802 Excl,
803 Star
804 }
805
806 enum RangeOp {
807 Dotdot,
808 Dotdoteq
809 }
810
811 enum LiteralToken {
812 IntNumber,
813 FloatNumber,
814 String,
815 RawString,
816 TrueKw,
817 FalseKw,
818 ByteString,
819 RawByteString,
820 Char,
821 Byte
822 }
823
824 enum NameRefToken {
825 Ident,
826 IntNumber
827 }
828 },
829}; 771};