Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitca6c054

Browse files
committed
Rust: RenameAdt class and lift common predicates to it
1 parent22bc924 commitca6c054

File tree

4 files changed

+34
-11
lines changed

4 files changed

+34
-11
lines changed

‎rust/ast-generator/src/main.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use ungrammar::Grammar;
1515

1616
fnclass_name(type_name:&str) ->String{
1717
match type_name{
18+
"Adt" =>"TypeItem".to_owned(),
1819
"BinExpr" =>"BinaryExpr".to_owned(),
1920
"ElseBranch" =>"Expr".to_owned(),
2021
"Fn" =>"Function".to_owned(),

‎rust/extractor/src/translate/base.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ impl<'a> Translator<'a> {
674674
pub(crate)fnemit_derive_expansion(
675675
&mutself,
676676
node:&(implInto<ast::Adt> +Clone),
677-
label:implInto<Label<generated::Adt>> +Copy,
677+
label:implInto<Label<generated::TypeItem>> +Copy,
678678
){
679679
letSome(semantics) =self.semanticselse{
680680
return;
@@ -686,7 +686,7 @@ impl<'a> Translator<'a> {
686686
.flatten()
687687
.filter_map(|expanded|self.process_item_macro_expansion(&node, expanded))
688688
.collect::<Vec<_>>();
689-
generated::Adt::emit_derive_macro_expansions(
689+
generated::TypeItem::emit_derive_macro_expansions(
690690
label.into(),
691691
expansions,
692692
&mutself.trap.writer,

‎rust/schema/annotations.py‎

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,18 @@ class LoopingExpr(LabelableExpr):
1818
loop_body:optional["BlockExpr"]|child
1919

2020

21-
@annotate(Adt,replace_bases={AstNode:Item})
21+
@annotate(TypeItem,replace_bases={AstNode:Item})
2222
class_:
2323
"""
24-
AnADT (Abstract Data Type) definition, such as `Struct`, `Enum`, or `Union`.
24+
Anitem that defines a type. Either a `Struct`, `Enum`, or `Union`.
2525
"""
2626

2727
derive_macro_expansions:list[MacroItems]|child|rust.detach
28+
attrs:list["Attr"]|child
29+
generic_param_list:optional["GenericParamList"]|child
30+
name:optional["Name"]|child
31+
visibility:optional["Visibility"]|child
32+
where_clause:optional["WhereClause"]|child
2833

2934

3035
@annotate(Module)
@@ -1063,7 +1068,7 @@ class _:
10631068
"""
10641069

10651070

1066-
@annotate(Enum,replace_bases={Item:None})# still an Item via Adt
1071+
@annotate(Enum,replace_bases={Item:None})
10671072
class_:
10681073
"""
10691074
An enum declaration.
@@ -1074,6 +1079,12 @@ class _:
10741079
```
10751080
"""
10761081

1082+
attrs:drop
1083+
generic_param_list:drop
1084+
name:drop
1085+
visibility:drop
1086+
where_clause:drop
1087+
10771088

10781089
@annotate(ExternBlock)
10791090
class_:
@@ -1893,7 +1904,7 @@ class _:
18931904
)
18941905

18951906

1896-
@annotate(Struct,replace_bases={Item:None})# still an Item via Adt
1907+
@annotate(Struct,replace_bases={Item:None})
18971908
class_:
18981909
"""
18991910
A Struct. For example:
@@ -1906,6 +1917,11 @@ class _:
19061917
"""
19071918

19081919
field_list:_|ql.db_table_name("struct_field_lists_")
1920+
attrs:drop
1921+
generic_param_list:drop
1922+
name:drop
1923+
visibility:drop
1924+
where_clause:drop
19091925

19101926

19111927
@annotate(TokenTree)
@@ -2075,7 +2091,7 @@ class _:
20752091
"""
20762092

20772093

2078-
@annotate(Union,replace_bases={Item:None})# still an Item via Adt
2094+
@annotate(Union,replace_bases={Item:None})
20792095
class_:
20802096
"""
20812097
A union declaration.
@@ -2086,6 +2102,12 @@ class _:
20862102
```
20872103
"""
20882104

2105+
attrs:drop
2106+
generic_param_list:drop
2107+
name:drop
2108+
visibility:drop
2109+
where_clause:drop
2110+
20892111

20902112
@annotate(Use)
20912113
class_:

‎rust/schema/ast.py‎

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp