This repository was archived by the owner on Aug 18, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +15
-8
lines changed
Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -52,34 +52,41 @@ impl<'a> EnumParser for ParserBase<'a> {
5252
5353 fn parse_enum_variant ( & mut self ) -> Result < EnumVariant , String > {
5454 debug_println ( "开始解析枚举变体" ) ;
55-
55+
5656 // 获取变体名
5757 let variant_name = self . consume ( ) . ok_or_else ( || "期望枚举变体名" . to_string ( ) ) ?;
5858 debug_println ( & format ! ( "解析枚举变体: {}" , variant_name) ) ;
59-
59+
6060 let mut fields = Vec :: new ( ) ;
61-
61+
62+ // 检查是否有显式值赋值(如 Success = 0)
63+ if self . peek ( ) == Some ( & "=" . to_string ( ) ) {
64+ self . consume ( ) ; // 消费 "="
65+ // 跳过值,暂时不处理显式值
66+ self . consume ( ) ; // 消费值
67+ }
68+
6269 // 检查是否有字段定义
6370 if self . peek ( ) == Some ( & "(" . to_string ( ) ) {
6471 self . consume ( ) ; // 消费 "("
65-
72+
6673 // 解析字段列表
6774 while self . peek ( ) != Some ( & ")" . to_string ( ) ) {
6875 let field = self . parse_enum_field ( ) ?;
6976 fields. push ( field) ;
70-
77+
7178 if self . peek ( ) == Some ( & "," . to_string ( ) ) {
7279 self . consume ( ) ; // 消费 ","
7380 } else if self . peek ( ) != Some ( & ")" . to_string ( ) ) {
7481 return Err ( "期望 ',' 或 ')'" . to_string ( ) ) ;
7582 }
7683 }
77-
84+
7885 self . expect ( ")" ) ?; // 期望 ")"
7986 }
80-
87+
8188 debug_println ( & format ! ( "枚举变体解析完成: {} (字段数: {})" , variant_name, fields. len( ) ) ) ;
82-
89+
8390 Ok ( EnumVariant {
8491 name : variant_name,
8592 fields,
You can’t perform that action at this time.
0 commit comments