diff options
author | Benjamin Coenen <[email protected]> | 2020-04-09 17:37:34 +0100 |
---|---|---|
committer | Benjamin Coenen <[email protected]> | 2020-04-09 18:12:50 +0100 |
commit | c1317d692321ba5ba8f138067ebefbb9559d098d (patch) | |
tree | e29a44577e4d2cf55b6f53e3428abea43bbd33d7 /xtask/src/ast_src.rs | |
parent | fc70cf9458c5234decafdd52b9aced790ac43d7a (diff) | |
parent | 30f0ad159a0f260f54356385de63c171722adb72 (diff) |
feat: add support for feature attributes in struct literal
Signed-off-by: Benjamin Coenen <[email protected]>
Diffstat (limited to 'xtask/src/ast_src.rs')
-rw-r--r-- | xtask/src/ast_src.rs | 378 |
1 files changed, 287 insertions, 91 deletions
diff --git a/xtask/src/ast_src.rs b/xtask/src/ast_src.rs index d9f51ec39..eba66ff4d 100644 --- a/xtask/src/ast_src.rs +++ b/xtask/src/ast_src.rs | |||
@@ -70,7 +70,7 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc { | |||
70 | "match", "mod", "move", "mut", "pub", "ref", "return", "self", "static", "struct", "super", | 70 | "match", "mod", "move", "mut", "pub", "ref", "return", "self", "static", "struct", "super", |
71 | "trait", "true", "try", "type", "unsafe", "use", "where", "while", | 71 | "trait", "true", "try", "type", "unsafe", "use", "where", "while", |
72 | ], | 72 | ], |
73 | contextual_keywords: &["auto", "default", "existential", "union"], | 73 | contextual_keywords: &["auto", "default", "existential", "union", "raw"], |
74 | literals: &[ | 74 | literals: &[ |
75 | "INT_NUMBER", | 75 | "INT_NUMBER", |
76 | "FLOAT_NUMBER", | 76 | "FLOAT_NUMBER", |
@@ -227,6 +227,7 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc { | |||
227 | pub(crate) struct AstSrc<'a> { | 227 | pub(crate) struct AstSrc<'a> { |
228 | pub(crate) nodes: &'a [AstNodeSrc<'a>], | 228 | pub(crate) nodes: &'a [AstNodeSrc<'a>], |
229 | pub(crate) enums: &'a [AstEnumSrc<'a>], | 229 | pub(crate) enums: &'a [AstEnumSrc<'a>], |
230 | pub(crate) token_enums: &'a [AstEnumSrc<'a>], | ||
230 | } | 231 | } |
231 | 232 | ||
232 | pub(crate) struct AstNodeSrc<'a> { | 233 | pub(crate) struct AstNodeSrc<'a> { |
@@ -297,235 +298,310 @@ macro_rules! ast_enums { | |||
297 | 298 | ||
298 | pub(crate) const AST_SRC: AstSrc = AstSrc { | 299 | pub(crate) const AST_SRC: AstSrc = AstSrc { |
299 | nodes: &ast_nodes! { | 300 | nodes: &ast_nodes! { |
300 | struct SourceFile: ModuleItemOwner, FnDefOwner { | 301 | struct SourceFile: ModuleItemOwner, FnDefOwner, AttrsOwner { |
301 | modules: [Module], | 302 | modules: [Module], |
302 | } | 303 | } |
303 | 304 | ||
304 | struct FnDef: VisibilityOwner, NameOwner, TypeParamsOwner, DocCommentsOwner, AttrsOwner { | 305 | struct FnDef: VisibilityOwner, NameOwner, TypeParamsOwner, DocCommentsOwner, AttrsOwner { |
306 | Abi, | ||
307 | ConstKw, | ||
308 | DefaultKw, | ||
309 | AsyncKw, | ||
310 | UnsafeKw, | ||
311 | FnKw, | ||
305 | ParamList, | 312 | ParamList, |
306 | RetType, | 313 | RetType, |
307 | body: BlockExpr, | 314 | body: BlockExpr, |
315 | Semi | ||
308 | } | 316 | } |
309 | 317 | ||
310 | struct RetType { TypeRef } | 318 | struct RetType { ThinArrow, TypeRef } |
311 | 319 | ||
312 | struct StructDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner { | 320 | struct StructDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner { |
321 | StructKw, | ||
322 | FieldDefList, | ||
323 | Semi | ||
313 | } | 324 | } |
314 | 325 | ||
315 | struct UnionDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner { | 326 | struct UnionDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner { |
327 | UnionKw, | ||
316 | RecordFieldDefList, | 328 | RecordFieldDefList, |
317 | } | 329 | } |
318 | 330 | ||
319 | struct RecordFieldDefList { fields: [RecordFieldDef] } | 331 | struct RecordFieldDefList { LCurly, fields: [RecordFieldDef], RCurly } |
320 | struct RecordFieldDef: VisibilityOwner, NameOwner, AttrsOwner, DocCommentsOwner, TypeAscriptionOwner { } | 332 | struct RecordFieldDef: VisibilityOwner, NameOwner, AttrsOwner, DocCommentsOwner, TypeAscriptionOwner { } |
321 | 333 | ||
322 | struct TupleFieldDefList { fields: [TupleFieldDef] } | 334 | struct TupleFieldDefList { LParen, fields: [TupleFieldDef], RParen } |
323 | struct TupleFieldDef: VisibilityOwner, AttrsOwner { | 335 | struct TupleFieldDef: VisibilityOwner, AttrsOwner { |
324 | TypeRef, | 336 | TypeRef, |
325 | } | 337 | } |
326 | 338 | ||
327 | struct EnumDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner { | 339 | struct EnumDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner { |
340 | EnumKw, | ||
328 | variant_list: EnumVariantList, | 341 | variant_list: EnumVariantList, |
329 | } | 342 | } |
330 | struct EnumVariantList { | 343 | struct EnumVariantList { |
344 | LCurly, | ||
331 | variants: [EnumVariant], | 345 | variants: [EnumVariant], |
346 | RCurly | ||
332 | } | 347 | } |
333 | struct EnumVariant: NameOwner, DocCommentsOwner, AttrsOwner { | 348 | struct EnumVariant: VisibilityOwner, NameOwner, DocCommentsOwner, AttrsOwner { |
349 | FieldDefList, | ||
350 | Eq, | ||
334 | Expr | 351 | Expr |
335 | } | 352 | } |
336 | 353 | ||
337 | struct TraitDef: VisibilityOwner, NameOwner, AttrsOwner, DocCommentsOwner, TypeParamsOwner, TypeBoundsOwner { | 354 | struct TraitDef: VisibilityOwner, NameOwner, AttrsOwner, DocCommentsOwner, TypeParamsOwner, TypeBoundsOwner { |
355 | UnsafeKw, | ||
356 | AutoKw, | ||
357 | TraitKw, | ||
338 | ItemList, | 358 | ItemList, |
339 | } | 359 | } |
340 | 360 | ||
341 | struct Module: VisibilityOwner, NameOwner, AttrsOwner, DocCommentsOwner { | 361 | struct Module: VisibilityOwner, NameOwner, AttrsOwner, DocCommentsOwner { |
362 | ModKw, | ||
342 | ItemList, | 363 | ItemList, |
364 | Semi | ||
343 | } | 365 | } |
344 | 366 | ||
345 | struct ItemList: FnDefOwner, ModuleItemOwner { | 367 | struct ItemList: FnDefOwner, ModuleItemOwner { |
368 | LCurly, | ||
346 | impl_items: [ImplItem], | 369 | impl_items: [ImplItem], |
370 | RCurly | ||
347 | } | 371 | } |
348 | 372 | ||
349 | struct ConstDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeAscriptionOwner { | 373 | struct ConstDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeAscriptionOwner { |
374 | DefaultKw, | ||
375 | ConstKw, | ||
376 | Eq, | ||
350 | body: Expr, | 377 | body: Expr, |
378 | Semi | ||
351 | } | 379 | } |
352 | 380 | ||
353 | struct StaticDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeAscriptionOwner { | 381 | struct StaticDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeAscriptionOwner { |
382 | StaticKw, | ||
383 | MutKw, | ||
384 | Eq, | ||
354 | body: Expr, | 385 | body: Expr, |
386 | Semi | ||
355 | } | 387 | } |
356 | 388 | ||
357 | struct TypeAliasDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeBoundsOwner { | 389 | struct TypeAliasDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeBoundsOwner { |
390 | DefaultKw, | ||
391 | TypeKw, | ||
392 | Eq, | ||
358 | TypeRef, | 393 | TypeRef, |
394 | Semi | ||
359 | } | 395 | } |
360 | 396 | ||
361 | struct ImplDef: TypeParamsOwner, AttrsOwner { | 397 | struct ImplDef: TypeParamsOwner, AttrsOwner { |
398 | DefaultKw, | ||
399 | ConstKw, | ||
400 | UnsafeKw, | ||
401 | ImplKw, | ||
402 | Excl, | ||
403 | ForKw, | ||
362 | ItemList, | 404 | ItemList, |
363 | } | 405 | } |
364 | 406 | ||
365 | struct ParenType { TypeRef } | 407 | struct ParenType { LParen, TypeRef, RParen } |
366 | struct TupleType { fields: [TypeRef] } | 408 | struct TupleType { LParen, fields: [TypeRef], RParen } |
367 | struct NeverType { } | 409 | struct NeverType { Excl } |
368 | struct PathType { Path } | 410 | struct PathType { Path } |
369 | struct PointerType { TypeRef } | 411 | struct PointerType { Star, ConstKw, TypeRef } |
370 | struct ArrayType { TypeRef, Expr } | 412 | struct ArrayType { LBrack, TypeRef, Semi, Expr, RBrack } |
371 | struct SliceType { TypeRef } | 413 | struct SliceType { LBrack, TypeRef, RBrack } |
372 | struct ReferenceType { TypeRef } | 414 | struct ReferenceType { Amp, Lifetime, MutKw, TypeRef } |
373 | struct PlaceholderType { } | 415 | struct PlaceholderType { Underscore } |
374 | struct FnPointerType { ParamList, RetType } | 416 | struct FnPointerType { Abi, UnsafeKw, FnKw, ParamList, RetType } |
375 | struct ForType { TypeRef } | 417 | struct ForType { ForKw, TypeParamList, TypeRef } |
376 | struct ImplTraitType: TypeBoundsOwner {} | 418 | struct ImplTraitType: TypeBoundsOwner { ImplKw } |
377 | struct DynTraitType: TypeBoundsOwner {} | 419 | struct DynTraitType: TypeBoundsOwner { DynKw } |
378 | 420 | ||
379 | struct TupleExpr { exprs: [Expr] } | 421 | struct TupleExpr: AttrsOwner { LParen, exprs: [Expr], RParen } |
380 | struct ArrayExpr { exprs: [Expr] } | 422 | struct ArrayExpr: AttrsOwner { LBrack, exprs: [Expr], Semi, RBrack } |
381 | struct ParenExpr { Expr } | 423 | struct ParenExpr: AttrsOwner { LParen, Expr, RParen } |
382 | struct PathExpr { Path } | 424 | struct PathExpr { Path } |
383 | struct LambdaExpr { | 425 | struct LambdaExpr: AttrsOwner { |
426 | StaticKw, | ||
427 | AsyncKw, | ||
428 | MoveKw, | ||
384 | ParamList, | 429 | ParamList, |
385 | RetType, | 430 | RetType, |
386 | body: Expr, | 431 | body: Expr, |
387 | } | 432 | } |
388 | struct IfExpr { Condition } | 433 | struct IfExpr: AttrsOwner { IfKw, Condition } |
389 | struct LoopExpr: LoopBodyOwner { } | 434 | struct LoopExpr: AttrsOwner, LoopBodyOwner { LoopKw } |
390 | struct TryBlockExpr { body: BlockExpr } | 435 | struct TryBlockExpr: AttrsOwner { TryKw, body: BlockExpr } |
391 | struct ForExpr: LoopBodyOwner { | 436 | struct ForExpr: AttrsOwner, LoopBodyOwner { |
437 | ForKw, | ||
392 | Pat, | 438 | Pat, |
439 | InKw, | ||
393 | iterable: Expr, | 440 | iterable: Expr, |
394 | } | 441 | } |
395 | struct WhileExpr: LoopBodyOwner { Condition } | 442 | struct WhileExpr: AttrsOwner, LoopBodyOwner { WhileKw, Condition } |
396 | struct ContinueExpr {} | 443 | struct ContinueExpr: AttrsOwner { ContinueKw, Lifetime } |
397 | struct BreakExpr { Expr } | 444 | struct BreakExpr: AttrsOwner { BreakKw, Lifetime, Expr } |
398 | struct Label {} | 445 | struct Label { Lifetime } |
399 | struct BlockExpr { Block } | 446 | struct BlockExpr: AttrsOwner { Label, UnsafeKw, Block } |
400 | struct ReturnExpr { Expr } | 447 | struct ReturnExpr: AttrsOwner { Expr } |
401 | struct CallExpr: ArgListOwner { Expr } | 448 | struct CallExpr: ArgListOwner { Expr } |
402 | struct MethodCallExpr: ArgListOwner { | 449 | struct MethodCallExpr: AttrsOwner, ArgListOwner { |
403 | Expr, NameRef, TypeArgList, | 450 | Expr, Dot, NameRef, TypeArgList, |
404 | } | 451 | } |
405 | struct IndexExpr {} | 452 | struct IndexExpr: AttrsOwner { LBrack, RBrack } |
406 | struct FieldExpr { Expr, NameRef } | 453 | struct FieldExpr: AttrsOwner { Expr, Dot, NameRef } |
407 | struct AwaitExpr { Expr } | 454 | struct AwaitExpr: AttrsOwner { Expr, Dot, AwaitKw } |
408 | struct TryExpr { Expr } | 455 | struct TryExpr: AttrsOwner { TryKw, Expr } |
409 | struct CastExpr { Expr, TypeRef } | 456 | struct CastExpr: AttrsOwner { Expr, AsKw, TypeRef } |
410 | struct RefExpr { Expr } | 457 | struct RefExpr: AttrsOwner { Amp, RawKw, MutKw, Expr } |
411 | struct PrefixExpr { Expr } | 458 | struct PrefixExpr: AttrsOwner { PrefixOp, Expr } |
412 | struct BoxExpr { Expr } | 459 | struct BoxExpr: AttrsOwner { BoxKw, Expr } |
413 | struct RangeExpr {} | 460 | struct RangeExpr: AttrsOwner { RangeOp } |
414 | struct BinExpr {} | 461 | struct BinExpr: AttrsOwner { BinOp } |
415 | struct Literal {} | 462 | struct Literal { LiteralToken } |
416 | 463 | ||
417 | struct MatchExpr { Expr, MatchArmList } | 464 | struct MatchExpr: AttrsOwner { MatchKw, Expr, MatchArmList } |
418 | struct MatchArmList: AttrsOwner { arms: [MatchArm] } | 465 | struct MatchArmList: AttrsOwner { LCurly, arms: [MatchArm], RCurly } |
419 | struct MatchArm: AttrsOwner { | 466 | struct MatchArm: AttrsOwner { |
420 | pat: Pat, | 467 | pat: Pat, |
421 | guard: MatchGuard, | 468 | guard: MatchGuard, |
469 | FatArrow, | ||
422 | Expr, | 470 | Expr, |
423 | } | 471 | } |
424 | struct MatchGuard { Expr } | 472 | struct MatchGuard { IfKw, Expr } |
425 | 473 | ||
426 | struct RecordLit { Path, RecordFieldList } | 474 | struct RecordLit { Path, RecordFieldList} |
427 | struct RecordFieldList { | 475 | struct RecordFieldList { |
476 | LCurly, | ||
428 | fields: [RecordField], | 477 | fields: [RecordField], |
478 | Dotdot, | ||
429 | spread: Expr, | 479 | spread: Expr, |
480 | RCurly | ||
430 | } | 481 | } |
431 | struct RecordField { NameRef, Expr } | 482 | struct RecordField: AttrsOwner { NameRef, Colon, Expr } |
432 | 483 | ||
433 | struct OrPat { pats: [Pat] } | 484 | struct OrPat { pats: [Pat] } |
434 | struct ParenPat { Pat } | 485 | struct ParenPat { LParen, Pat, RParen } |
435 | struct RefPat { Pat } | 486 | struct RefPat { Amp, MutKw, Pat } |
436 | struct BoxPat { Pat } | 487 | struct BoxPat { BoxKw, Pat } |
437 | struct BindPat: NameOwner { Pat } | 488 | struct BindPat: AttrsOwner, NameOwner { RefKw, MutKw, Pat } |
438 | struct PlaceholderPat { } | 489 | struct PlaceholderPat { Underscore } |
439 | struct DotDotPat { } | 490 | struct DotDotPat { Dotdot } |
440 | struct PathPat { Path } | 491 | struct PathPat { Path } |
441 | struct SlicePat { args: [Pat] } | 492 | struct SlicePat { LBrack, args: [Pat], RBrack } |
442 | struct RangePat {} | 493 | struct RangePat { RangeSeparator } |
443 | struct LiteralPat { Literal } | 494 | struct LiteralPat { Literal } |
444 | struct MacroPat { MacroCall } | 495 | struct MacroPat { MacroCall } |
445 | 496 | ||
446 | struct RecordPat { RecordFieldPatList, Path } | 497 | struct RecordPat { RecordFieldPatList, Path } |
447 | struct RecordFieldPatList { | 498 | struct RecordFieldPatList { |
499 | LCurly, | ||
500 | pats: [RecordInnerPat], | ||
448 | record_field_pats: [RecordFieldPat], | 501 | record_field_pats: [RecordFieldPat], |
449 | bind_pats: [BindPat], | 502 | bind_pats: [BindPat], |
503 | Dotdot, | ||
504 | RCurly | ||
450 | } | 505 | } |
451 | struct RecordFieldPat: NameOwner { Pat } | 506 | struct RecordFieldPat: AttrsOwner, NameOwner { Colon, Pat } |
452 | 507 | ||
453 | struct TupleStructPat { Path, args: [Pat] } | 508 | struct TupleStructPat { Path, LParen, args: [Pat], RParen } |
454 | struct TuplePat { args: [Pat] } | 509 | struct TuplePat { LParen, args: [Pat], RParen } |
455 | 510 | ||
456 | struct Visibility {} | 511 | struct Visibility { PubKw, SuperKw, SelfKw, CrateKw } |
457 | struct Name {} | 512 | struct Name { Ident } |
458 | struct NameRef {} | 513 | struct NameRef { NameRefToken } |
459 | 514 | ||
460 | struct MacroCall: NameOwner, AttrsOwner,DocCommentsOwner { | 515 | struct MacroCall: NameOwner, AttrsOwner,DocCommentsOwner { |
461 | TokenTree, Path | 516 | Path, Excl, TokenTree, Semi |
462 | } | 517 | } |
463 | struct Attr { Path, input: AttrInput } | 518 | struct Attr { Pound, Excl, LBrack, Path, Eq, input: AttrInput, RBrack } |
464 | struct TokenTree {} | 519 | struct TokenTree {} |
465 | struct TypeParamList { | 520 | struct TypeParamList { |
521 | LAngle, | ||
522 | generic_params: [GenericParam], | ||
466 | type_params: [TypeParam], | 523 | type_params: [TypeParam], |
467 | lifetime_params: [LifetimeParam], | 524 | lifetime_params: [LifetimeParam], |
525 | const_params: [ConstParam], | ||
526 | RAngle | ||
468 | } | 527 | } |
469 | struct TypeParam: NameOwner, AttrsOwner, TypeBoundsOwner { | 528 | struct TypeParam: NameOwner, AttrsOwner, TypeBoundsOwner { |
529 | Eq, | ||
470 | default_type: TypeRef, | 530 | default_type: TypeRef, |
471 | } | 531 | } |
472 | struct ConstParam: NameOwner, AttrsOwner, TypeAscriptionOwner { | 532 | struct ConstParam: NameOwner, AttrsOwner, TypeAscriptionOwner { |
533 | Eq, | ||
473 | default_val: Expr, | 534 | default_val: Expr, |
474 | } | 535 | } |
475 | struct LifetimeParam: AttrsOwner { } | 536 | struct LifetimeParam: AttrsOwner { Lifetime} |
476 | struct TypeBound { TypeRef} | 537 | struct TypeBound { Lifetime, /* Question, */ ConstKw, /* Question, */ TypeRef} |
477 | struct TypeBoundList { bounds: [TypeBound] } | 538 | struct TypeBoundList { bounds: [TypeBound] } |
478 | struct WherePred: TypeBoundsOwner { TypeRef } | 539 | struct WherePred: TypeBoundsOwner { Lifetime, TypeRef } |
479 | struct WhereClause { predicates: [WherePred] } | 540 | struct WhereClause { WhereKw, predicates: [WherePred] } |
480 | struct ExprStmt { Expr } | 541 | struct Abi { String } |
481 | struct LetStmt: TypeAscriptionOwner { | 542 | struct ExprStmt: AttrsOwner { Expr, Semi } |
543 | struct LetStmt: AttrsOwner, TypeAscriptionOwner { | ||
544 | LetKw, | ||
482 | Pat, | 545 | Pat, |
546 | Eq, | ||
483 | initializer: Expr, | 547 | initializer: Expr, |
484 | } | 548 | } |
485 | struct Condition { Pat, Expr } | 549 | struct Condition { LetKw, Pat, Eq, Expr } |
486 | struct Block: AttrsOwner, ModuleItemOwner { | 550 | struct Block: AttrsOwner, ModuleItemOwner { |
551 | LCurly, | ||
487 | statements: [Stmt], | 552 | statements: [Stmt], |
488 | Expr, | 553 | Expr, |
554 | RCurly, | ||
489 | } | 555 | } |
490 | struct ParamList { | 556 | struct ParamList { |
557 | LParen, | ||
491 | SelfParam, | 558 | SelfParam, |
492 | params: [Param], | 559 | params: [Param], |
560 | RParen | ||
493 | } | 561 | } |
494 | struct SelfParam: TypeAscriptionOwner, AttrsOwner { } | 562 | struct SelfParam: TypeAscriptionOwner, AttrsOwner { Amp, Lifetime, SelfKw } |
495 | struct Param: TypeAscriptionOwner, AttrsOwner { | 563 | struct Param: TypeAscriptionOwner, AttrsOwner { |
496 | Pat, | 564 | Pat, |
565 | Dotdotdot | ||
497 | } | 566 | } |
498 | struct UseItem: AttrsOwner, VisibilityOwner { | 567 | struct UseItem: AttrsOwner, VisibilityOwner { |
568 | UseKw, | ||
499 | UseTree, | 569 | UseTree, |
500 | } | 570 | } |
501 | struct UseTree { | 571 | struct UseTree { |
502 | Path, UseTreeList, Alias | 572 | Path, Star, UseTreeList, Alias |
503 | } | 573 | } |
504 | struct Alias: NameOwner { } | 574 | struct Alias: NameOwner { AsKw } |
505 | struct UseTreeList { use_trees: [UseTree] } | 575 | struct UseTreeList { LCurly, use_trees: [UseTree], RCurly } |
506 | struct ExternCrateItem: AttrsOwner, VisibilityOwner { | 576 | struct ExternCrateItem: AttrsOwner, VisibilityOwner { |
507 | NameRef, Alias, | 577 | ExternKw, CrateKw, NameRef, Alias, |
508 | } | 578 | } |
509 | struct ArgList { | 579 | struct ArgList { |
580 | LParen, | ||
510 | args: [Expr], | 581 | args: [Expr], |
582 | RParen | ||
511 | } | 583 | } |
512 | struct Path { | 584 | struct Path { |
513 | segment: PathSegment, | 585 | segment: PathSegment, |
514 | qualifier: Path, | 586 | qualifier: Path, |
515 | } | 587 | } |
516 | struct PathSegment { | 588 | struct PathSegment { |
517 | NameRef, TypeArgList, ParamList, RetType, PathType, | 589 | Coloncolon, LAngle, NameRef, TypeArgList, ParamList, RetType, PathType, RAngle |
518 | } | 590 | } |
519 | struct TypeArgList { | 591 | struct TypeArgList { |
592 | Coloncolon, | ||
593 | LAngle, | ||
594 | generic_args: [GenericArg], | ||
520 | type_args: [TypeArg], | 595 | type_args: [TypeArg], |
521 | lifetime_args: [LifetimeArg], | 596 | lifetime_args: [LifetimeArg], |
522 | assoc_type_args: [AssocTypeArg], | 597 | assoc_type_args: [AssocTypeArg], |
523 | const_arg: [ConstArg], | 598 | const_args: [ConstArg], |
599 | RAngle | ||
524 | } | 600 | } |
525 | struct TypeArg { TypeRef } | 601 | struct TypeArg { TypeRef } |
526 | struct AssocTypeArg { NameRef, TypeRef } | 602 | struct AssocTypeArg : TypeBoundsOwner { NameRef, Eq, TypeRef } |
527 | struct LifetimeArg {} | 603 | struct LifetimeArg { Lifetime } |
528 | struct ConstArg { Literal, BlockExpr } | 604 | struct ConstArg { Literal, Eq, BlockExpr } |
529 | 605 | ||
530 | struct MacroItems: ModuleItemOwner, FnDefOwner { } | 606 | struct MacroItems: ModuleItemOwner, FnDefOwner { } |
531 | 607 | ||
@@ -533,12 +609,44 @@ pub(crate) const AST_SRC: AstSrc = AstSrc { | |||
533 | statements: [Stmt], | 609 | statements: [Stmt], |
534 | Expr, | 610 | Expr, |
535 | } | 611 | } |
612 | |||
613 | struct ExternItemList: FnDefOwner, ModuleItemOwner { | ||
614 | LCurly, | ||
615 | extern_items: [ExternItem], | ||
616 | RCurly | ||
617 | } | ||
618 | |||
619 | struct ExternBlock { | ||
620 | Abi, | ||
621 | ExternItemList | ||
622 | } | ||
623 | |||
624 | struct MetaItem { | ||
625 | Path, Eq, AttrInput, nested_meta_items: [MetaItem] | ||
626 | } | ||
627 | |||
628 | struct MacroDef { | ||
629 | Name, TokenTree | ||
630 | } | ||
536 | }, | 631 | }, |
537 | enums: &ast_enums! { | 632 | enums: &ast_enums! { |
538 | enum NominalDef: NameOwner, TypeParamsOwner, AttrsOwner { | 633 | enum NominalDef: NameOwner, TypeParamsOwner, AttrsOwner { |
539 | StructDef, EnumDef, UnionDef, | 634 | StructDef, EnumDef, UnionDef, |
540 | } | 635 | } |
541 | 636 | ||
637 | enum GenericParam { | ||
638 | LifetimeParam, | ||
639 | TypeParam, | ||
640 | ConstParam | ||
641 | } | ||
642 | |||
643 | enum GenericArg { | ||
644 | LifetimeArg, | ||
645 | TypeArg, | ||
646 | ConstArg, | ||
647 | AssocTypeArg | ||
648 | } | ||
649 | |||
542 | enum TypeRef { | 650 | enum TypeRef { |
543 | ParenType, | 651 | ParenType, |
544 | TupleType, | 652 | TupleType, |
@@ -555,7 +663,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc { | |||
555 | DynTraitType, | 663 | DynTraitType, |
556 | } | 664 | } |
557 | 665 | ||
558 | enum ModuleItem: AttrsOwner, VisibilityOwner { | 666 | enum ModuleItem: NameOwner, AttrsOwner, VisibilityOwner { |
559 | StructDef, | 667 | StructDef, |
560 | UnionDef, | 668 | UnionDef, |
561 | EnumDef, | 669 | EnumDef, |
@@ -569,13 +677,20 @@ pub(crate) const AST_SRC: AstSrc = AstSrc { | |||
569 | StaticDef, | 677 | StaticDef, |
570 | Module, | 678 | Module, |
571 | MacroCall, | 679 | MacroCall, |
680 | ExternBlock | ||
572 | } | 681 | } |
573 | 682 | ||
574 | enum ImplItem: AttrsOwner { | 683 | /* impl blocks can also contain MacroCall */ |
575 | FnDef, TypeAliasDef, ConstDef, | 684 | enum ImplItem: NameOwner, AttrsOwner { |
685 | FnDef, TypeAliasDef, ConstDef | ||
576 | } | 686 | } |
577 | 687 | ||
578 | enum Expr { | 688 | /* extern blocks can also contain MacroCall */ |
689 | enum ExternItem: NameOwner, AttrsOwner, VisibilityOwner { | ||
690 | FnDef, StaticDef | ||
691 | } | ||
692 | |||
693 | enum Expr: AttrsOwner { | ||
579 | TupleExpr, | 694 | TupleExpr, |
580 | ArrayExpr, | 695 | ArrayExpr, |
581 | ParenExpr, | 696 | ParenExpr, |
@@ -627,7 +742,88 @@ pub(crate) const AST_SRC: AstSrc = AstSrc { | |||
627 | MacroPat, | 742 | MacroPat, |
628 | } | 743 | } |
629 | 744 | ||
745 | enum RecordInnerPat { | ||
746 | RecordFieldPat, | ||
747 | BindPat | ||
748 | } | ||
749 | |||
630 | enum AttrInput { Literal, TokenTree } | 750 | enum AttrInput { Literal, TokenTree } |
631 | enum Stmt { ExprStmt, LetStmt } | 751 | enum Stmt { |
752 | LetStmt, | ||
753 | ExprStmt, | ||
754 | // macro calls are parsed as expression statements */ | ||
755 | } | ||
756 | |||
757 | enum FieldDefList { | ||
758 | RecordFieldDefList, | ||
759 | TupleFieldDefList, | ||
760 | } | ||
761 | }, | ||
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 | } | ||
632 | }, | 828 | }, |
633 | }; | 829 | }; |