From a87edfb7122ed74a4115c00f0b30b659541542d1 Mon Sep 17 00:00:00 2001 From: myfreess Date: Fri, 9 Jan 2026 17:46:17 +0800 Subject: [PATCH 1/2] migrate to new moonbit toolchain release --- attribute/moon.pkg | 16 + attribute/moon.pkg.json | 15 - attribute/parser.mbt | 44 +- basic/moon.pkg | 0 basic/moon.pkg.json | 1 - handrolled_parser/moon.pkg | 9 + handrolled_parser/moon.pkg.json | 12 - lexer/moon.pkg | 1 + lexer/moon.pkg.json | 6 - mbti_ast/moon.pkg | 1 + mbti_ast/moon.pkg.json | 6 - mbti_parser/mbti_parser.mbt | 253 +++++--- mbti_parser/moon.pkg | 18 + mbti_parser/moon.pkg.json | 17 - moon.pkg | 9 + moon.pkg.json | 11 - syntax/moon.pkg | 9 + syntax/moon.pkg.json | 8 - syntax/util/moon.pkg | 8 + syntax/util/moon.pkg.json | 9 - test/manual_test/moon.pkg | 6 + test/manual_test/moon.pkg.json | 8 - test/mbti_parser_test/gen_test/moon.pkg | 5 + test/mbti_parser_test/gen_test/moon.pkg.json | 6 - test/mbti_parser_test/moon.pkg | 12 + test/mbti_parser_test/moon.pkg.json | 11 - test/sync_test/generator/moon.pkg | 5 + test/sync_test/generator/moon.pkg.json | 6 - test/sync_test/moon.pkg | 8 + test/sync_test/moon.pkg.json | 10 - tokens/{moon.pkg.json => moon.pkg} | 13 +- yacc_parser/moon.pkg | 18 + yacc_parser/moon.pkg.json | 17 - yacc_parser/parser.mbt | 612 +++++++++++++------ 34 files changed, 777 insertions(+), 413 deletions(-) create mode 100644 attribute/moon.pkg delete mode 100644 attribute/moon.pkg.json create mode 100644 basic/moon.pkg delete mode 100644 basic/moon.pkg.json create mode 100644 handrolled_parser/moon.pkg delete mode 100644 handrolled_parser/moon.pkg.json create mode 100644 lexer/moon.pkg delete mode 100644 lexer/moon.pkg.json create mode 100644 mbti_ast/moon.pkg delete mode 100644 mbti_ast/moon.pkg.json create mode 100644 mbti_parser/moon.pkg delete mode 100644 mbti_parser/moon.pkg.json create mode 100644 moon.pkg delete mode 100644 moon.pkg.json create mode 100644 syntax/moon.pkg delete mode 100644 syntax/moon.pkg.json create mode 100644 syntax/util/moon.pkg delete mode 100644 syntax/util/moon.pkg.json create mode 100644 test/manual_test/moon.pkg delete mode 100644 test/manual_test/moon.pkg.json create mode 100644 test/mbti_parser_test/gen_test/moon.pkg delete mode 100644 test/mbti_parser_test/gen_test/moon.pkg.json create mode 100644 test/mbti_parser_test/moon.pkg delete mode 100644 test/mbti_parser_test/moon.pkg.json create mode 100644 test/sync_test/generator/moon.pkg delete mode 100644 test/sync_test/generator/moon.pkg.json create mode 100644 test/sync_test/moon.pkg delete mode 100644 test/sync_test/moon.pkg.json rename tokens/{moon.pkg.json => moon.pkg} (71%) create mode 100644 yacc_parser/moon.pkg delete mode 100644 yacc_parser/moon.pkg.json diff --git a/attribute/moon.pkg b/attribute/moon.pkg new file mode 100644 index 00000000..ab2f8cbc --- /dev/null +++ b/attribute/moon.pkg @@ -0,0 +1,16 @@ +import { + "moonbitlang/parser/tokens", + "moonbitlang/parser/lexer", + "moonbitlang/parser/basic", +} + +options( + "pre-build": [ + { + "command": "$mod_dir/.mooncakes/moonbitlang/yacc/moonyacc --external-tokens --input-mode array $input -o $output && moonfmt -w $output && moonfmt -w $output", + "input": "parser.mbty", + "output": "parser.mbt", + }, + ], + "warn-list": "-6-3", +) \ No newline at end of file diff --git a/attribute/moon.pkg.json b/attribute/moon.pkg.json deleted file mode 100644 index 0a60a6e1..00000000 --- a/attribute/moon.pkg.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "pre-build": [ - { - "command": "$mod_dir/.mooncakes/moonbitlang/yacc/moonyacc --external-tokens --input-mode array $input -o $output && moonfmt -w $output && moonfmt -w $output", - "input": "parser.mbty", - "output": "parser.mbt" - } - ], - "import": [ - "moonbitlang/parser/tokens", - "moonbitlang/parser/lexer", - "moonbitlang/parser/basic" - ], - "warn-list": "-6-3" -} \ No newline at end of file diff --git a/attribute/parser.mbt b/attribute/parser.mbt index 0b52bf4d..0c1888f4 100644 --- a/attribute/parser.mbt +++ b/attribute/parser.mbt @@ -11,37 +11,59 @@ type YYObj = Error priv suberror YYObj_Void ///| -priv suberror YYObj_Int Int +priv suberror YYObj_Int { + YYObj_Int(Int) +} ///| -priv suberror YYObj_Bool Bool +priv suberror YYObj_Bool { + YYObj_Bool(Bool) +} ///| -priv suberror YYObj_Expr Expr +priv suberror YYObj_Expr { + YYObj_Expr(Expr) +} ///| -priv suberror YYObj_List_Prop_ List[Prop] +priv suberror YYObj_List_Prop_ { + YYObj_List_Prop_(List[Prop]) +} ///| -priv suberror YYObj_Prop Prop +priv suberror YYObj_Prop { + YYObj_Prop(Prop) +} ///| -priv suberror YYObj_String String +priv suberror YYObj_String { + YYObj_String(String) +} ///| -priv suberror YYObj_Comment Comment +priv suberror YYObj_Comment { + YYObj_Comment(Comment) +} ///| -priv suberror YYObj_CharLiteral CharLiteral +priv suberror YYObj_CharLiteral { + YYObj_CharLiteral(CharLiteral) +} ///| -priv suberror YYObj_InterpLiteral InterpLiteral +priv suberror YYObj_InterpLiteral { + YYObj_InterpLiteral(InterpLiteral) +} ///| -priv suberror YYObj_StringLiteral StringLiteral +priv suberror YYObj_StringLiteral { + YYObj_StringLiteral(StringLiteral) +} ///| -priv suberror YYObj__String__String___String_ (String, String?, String) +priv suberror YYObj__String__String___String_ { + YYObj__String__String___String_((String, String?, String)) +} ///| type YYState = (YYSymbol) -> YYDecision diff --git a/basic/moon.pkg b/basic/moon.pkg new file mode 100644 index 00000000..e69de29b diff --git a/basic/moon.pkg.json b/basic/moon.pkg.json deleted file mode 100644 index 9e26dfee..00000000 --- a/basic/moon.pkg.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/handrolled_parser/moon.pkg b/handrolled_parser/moon.pkg new file mode 100644 index 00000000..59f9d7d0 --- /dev/null +++ b/handrolled_parser/moon.pkg @@ -0,0 +1,9 @@ +import { + "moonbitlang/parser/syntax", + "moonbitlang/parser/tokens", + "moonbitlang/parser/syntax/util", + "moonbitlang/parser/basic", + "moonbitlang/parser/attribute", +} + +import "test" { "moonbitlang/parser/lexer" } \ No newline at end of file diff --git a/handrolled_parser/moon.pkg.json b/handrolled_parser/moon.pkg.json deleted file mode 100644 index 14dacecc..00000000 --- a/handrolled_parser/moon.pkg.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "import": [ - "moonbitlang/parser/syntax", - "moonbitlang/parser/tokens", - "moonbitlang/parser/syntax/util", - "moonbitlang/parser/basic", - "moonbitlang/parser/attribute" - ], - "test-import": [ - "moonbitlang/parser/lexer" - ] -} \ No newline at end of file diff --git a/lexer/moon.pkg b/lexer/moon.pkg new file mode 100644 index 00000000..fae6dc61 --- /dev/null +++ b/lexer/moon.pkg @@ -0,0 +1 @@ +import { "moonbitlang/parser/tokens", "moonbitlang/parser/basic" } \ No newline at end of file diff --git a/lexer/moon.pkg.json b/lexer/moon.pkg.json deleted file mode 100644 index 253ece8d..00000000 --- a/lexer/moon.pkg.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "import": [ - "moonbitlang/parser/tokens", - "moonbitlang/parser/basic" - ] -} diff --git a/mbti_ast/moon.pkg b/mbti_ast/moon.pkg new file mode 100644 index 00000000..2f31b8c4 --- /dev/null +++ b/mbti_ast/moon.pkg @@ -0,0 +1 @@ +import { "moonbitlang/parser/basic", "moonbitlang/parser/syntax" } \ No newline at end of file diff --git a/mbti_ast/moon.pkg.json b/mbti_ast/moon.pkg.json deleted file mode 100644 index 2d5bd8c0..00000000 --- a/mbti_ast/moon.pkg.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "import": [ - "moonbitlang/parser/basic", - "moonbitlang/parser/syntax" - ] -} diff --git a/mbti_parser/mbti_parser.mbt b/mbti_parser/mbti_parser.mbt index e453e13e..c5e0ab0e 100644 --- a/mbti_parser/mbti_parser.mbt +++ b/mbti_parser/mbti_parser.mbt @@ -11,192 +11,305 @@ type YYObj = Error priv suberror YYObj_Void ///| -priv suberror YYObj_Int Int +priv suberror YYObj_Int { + YYObj_Int(Int) +} ///| -priv suberror YYObj_Sig Sig +priv suberror YYObj_Sig { + YYObj_Sig(Sig) +} ///| -priv suberror YYObj_Bool Bool +priv suberror YYObj_Bool { + YYObj_Bool(Bool) +} ///| -priv suberror YYObj_Mbti Mbti +priv suberror YYObj_Mbti { + YYObj_Mbti(Mbti) +} ///| -priv suberror YYObj_Name Name +priv suberror YYObj_Name { + YYObj_Name(Name) +} ///| -priv suberror YYObj_Type Type +priv suberror YYObj_Type { + YYObj_Type(Type) +} ///| -priv suberror YYObj_Unit Unit +priv suberror YYObj_Unit { + YYObj_Unit(Unit) +} ///| -priv suberror YYObj_Label Label +priv suberror YYObj_Label { + YYObj_Label(Label) +} ///| -priv suberror YYObj_Option_Bool_ Bool? +priv suberror YYObj_Option_Bool_ { + YYObj_Option_Bool_(Bool?) +} ///| -priv suberror YYObj_Option_Name_ Name? +priv suberror YYObj_Option_Name_ { + YYObj_Option_Name_(Name?) +} ///| -priv suberror YYObj_Option__list_List_Type__ @list.List[Type]? +priv suberror YYObj_Option__list_List_Type__ { + YYObj_Option__list_List_Type__(@list.List[Type]?) +} ///| -priv suberror YYObj_Option__list_List_ConstrParam__ @list.List[ConstrParam]? +priv suberror YYObj_Option__list_List_ConstrParam__ { + YYObj_Option__list_List_ConstrParam__(@list.List[ConstrParam]?) +} ///| -priv suberror YYObj_Option__String__Location__ (String, Location)? +priv suberror YYObj_Option__String__Location__ { + YYObj_Option__String__Location__((String, Location)?) +} ///| -priv suberror YYObj_String String +priv suberror YYObj_String { + YYObj_String(String) +} ///| -priv suberror YYObj_Comment Comment +priv suberror YYObj_Comment { + YYObj_Comment(Comment) +} ///| -priv suberror YYObj_FuncSig FuncSig +priv suberror YYObj_FuncSig { + YYObj_FuncSig(FuncSig) +} ///| -priv suberror YYObj_ImplSig ImplSig +priv suberror YYObj_ImplSig { + YYObj_ImplSig(ImplSig) +} ///| -priv suberror YYObj_TypeSig TypeSig +priv suberror YYObj_TypeSig { + YYObj_TypeSig(TypeSig) +} ///| -priv suberror YYObj_AliasSig AliasSig +priv suberror YYObj_AliasSig { + YYObj_AliasSig(AliasSig) +} ///| -priv suberror YYObj_ConstSig ConstSig +priv suberror YYObj_ConstSig { + YYObj_ConstSig(ConstSig) +} ///| -priv suberror YYObj_Constant Constant +priv suberror YYObj_Constant { + YYObj_Constant(Constant) +} ///| -priv suberror YYObj_ConstrId ConstrId +priv suberror YYObj_ConstrId { + YYObj_ConstrId(ConstrId) +} ///| -priv suberror YYObj_TraitSig TraitSig +priv suberror YYObj_TraitSig { + YYObj_TraitSig(TraitSig) +} ///| -priv suberror YYObj_ValueSig ValueSig +priv suberror YYObj_ValueSig { + YYObj_ValueSig(ValueSig) +} ///| -priv suberror YYObj_Attribute Attribute +priv suberror YYObj_Attribute { + YYObj_Attribute(Attribute) +} ///| -priv suberror YYObj_FieldDecl FieldDecl +priv suberror YYObj_FieldDecl { + YYObj_FieldDecl(FieldDecl) +} ///| -priv suberror YYObj_Parameter Parameter +priv suberror YYObj_Parameter { + YYObj_Parameter(Parameter) +} ///| -priv suberror YYObj_ConstrDecl ConstrDecl +priv suberror YYObj_ConstrDecl { + YYObj_ConstrDecl(ConstrDecl) +} ///| -priv suberror YYObj_Visibility Visibility +priv suberror YYObj_Visibility { + YYObj_Visibility(Visibility) +} ///| -priv suberror YYObj_CharLiteral CharLiteral +priv suberror YYObj_CharLiteral { + YYObj_CharLiteral(CharLiteral) +} ///| -priv suberror YYObj_ConstrParam ConstrParam +priv suberror YYObj_ConstrParam { + YYObj_ConstrParam(ConstrParam) +} ///| -priv suberror YYObj_InterpLiteral InterpLiteral +priv suberror YYObj_InterpLiteral { + YYObj_InterpLiteral(InterpLiteral) +} ///| -priv suberror YYObj_PackageImport PackageImport +priv suberror YYObj_PackageImport { + YYObj_PackageImport(PackageImport) +} ///| -priv suberror YYObj_QualifiedName QualifiedName +priv suberror YYObj_QualifiedName { + YYObj_QualifiedName(QualifiedName) +} ///| -priv suberror YYObj_StringLiteral StringLiteral +priv suberror YYObj_StringLiteral { + YYObj_StringLiteral(StringLiteral) +} ///| -priv suberror YYObj_TraitMethodSig TraitMethodSig +priv suberror YYObj_TraitMethodSig { + YYObj_TraitMethodSig(TraitMethodSig) +} ///| -priv suberror YYObj_TraitMethodParameter TraitMethodParameter +priv suberror YYObj_TraitMethodParameter { + YYObj_TraitMethodParameter(TraitMethodParameter) +} ///| -priv suberror YYObj_TypeParamNoConstraints TypeParamNoConstraints +priv suberror YYObj_TypeParamNoConstraints { + YYObj_TypeParamNoConstraints(TypeParamNoConstraints) +} ///| -priv suberror YYObj_TypeParamWithConstraints TypeParamWithConstraints +priv suberror YYObj_TypeParamWithConstraints { + YYObj_TypeParamWithConstraints(TypeParamWithConstraints) +} ///| -priv suberror YYObj__list_List_Type_ @list.List[Type] +priv suberror YYObj__list_List_Type_ { + YYObj__list_List_Type_(@list.List[Type]) +} ///| -priv suberror YYObj__list_List_Attribute_ @list.List[Attribute] +priv suberror YYObj__list_List_Attribute_ { + YYObj__list_List_Attribute_(@list.List[Attribute]) +} ///| -priv suberror YYObj__list_List_FieldDecl_ @list.List[FieldDecl] +priv suberror YYObj__list_List_FieldDecl_ { + YYObj__list_List_FieldDecl_(@list.List[FieldDecl]) +} ///| -priv suberror YYObj__list_List_Parameter_ @list.List[Parameter] +priv suberror YYObj__list_List_Parameter_ { + YYObj__list_List_Parameter_(@list.List[Parameter]) +} ///| -priv suberror YYObj__list_List_ConstrDecl_ @list.List[ConstrDecl] +priv suberror YYObj__list_List_ConstrDecl_ { + YYObj__list_List_ConstrDecl_(@list.List[ConstrDecl]) +} ///| -priv suberror YYObj__list_List_ConstrParam_ @list.List[ConstrParam] +priv suberror YYObj__list_List_ConstrParam_ { + YYObj__list_List_ConstrParam_(@list.List[ConstrParam]) +} ///| -priv suberror YYObj__list_List_PackageImport_ @list.List[PackageImport] +priv suberror YYObj__list_List_PackageImport_ { + YYObj__list_List_PackageImport_(@list.List[PackageImport]) +} ///| -priv suberror YYObj__list_List_QualifiedName_ @list.List[QualifiedName] +priv suberror YYObj__list_List_QualifiedName_ { + YYObj__list_List_QualifiedName_(@list.List[QualifiedName]) +} ///| -priv suberror YYObj__list_List_TraitMethodSig_ @list.List[TraitMethodSig] +priv suberror YYObj__list_List_TraitMethodSig_ { + YYObj__list_List_TraitMethodSig_(@list.List[TraitMethodSig]) +} ///| -priv suberror YYObj__list_List_TraitMethodParameter_ @list.List[ - TraitMethodParameter, -] +priv suberror YYObj__list_List_TraitMethodParameter_ { + YYObj__list_List_TraitMethodParameter_(@list.List[TraitMethodParameter]) +} ///| -priv suberror YYObj__list_List_TypeParamNoConstraints_ @list.List[ - TypeParamNoConstraints, -] +priv suberror YYObj__list_List_TypeParamNoConstraints_ { + YYObj__list_List_TypeParamNoConstraints_(@list.List[TypeParamNoConstraints]) +} ///| -priv suberror YYObj__list_List_TypeParamWithConstraints_ @list.List[ - TypeParamWithConstraints, -] +priv suberror YYObj__list_List_TypeParamWithConstraints_ { + YYObj__list_List_TypeParamWithConstraints_( + @list.List[TypeParamWithConstraints] + ) +} ///| -priv suberror YYObj__list_List__Sig__Location__ @list.List[(Sig, Location)] +priv suberror YYObj__list_List__Sig__Location__ { + YYObj__list_List__Sig__Location__(@list.List[(Sig, Location)]) +} ///| -priv suberror YYObj__list_List__String__Option_String___String__ @list.List[ - (String, String?, String), -] +priv suberror YYObj__list_List__String__Option_String___String__ { + YYObj__list_List__String__Option_String___String__( + @list.List[(String, String?, String)] + ) +} ///| -priv suberror YYObj_String_ String? +priv suberror YYObj_String_ { + YYObj_String_(String?) +} ///| -priv suberror YYObj_Location_ Location? +priv suberror YYObj_Location_ { + YYObj_Location_(Location?) +} ///| -priv suberror YYObj__Name___list_List_TypeParamNoConstraints__ ( - Name, - @list.List[TypeParamNoConstraints], -) +priv suberror YYObj__Name___list_List_TypeParamNoConstraints__ { + YYObj__Name___list_List_TypeParamNoConstraints__( + (Name, @list.List[TypeParamNoConstraints]) + ) +} ///| -priv suberror YYObj__Type__ErrorType_ (Type, ErrorType) +priv suberror YYObj__Type__ErrorType_ { + YYObj__Type__ErrorType_((Type, ErrorType)) +} ///| -priv suberror YYObj__String__Location_ (String, Location) +priv suberror YYObj__String__Location_ { + YYObj__String__Location_((String, Location)) +} ///| -priv suberror YYObj__String__Option_String___String_ (String, String?, String) +priv suberror YYObj__String__Option_String___String_ { + YYObj__String__Option_String___String_((String, String?, String)) +} ///| type YYState = (YYSymbol) -> YYDecision diff --git a/mbti_parser/moon.pkg b/mbti_parser/moon.pkg new file mode 100644 index 00000000..6735464e --- /dev/null +++ b/mbti_parser/moon.pkg @@ -0,0 +1,18 @@ +import { + "moonbitlang/parser/tokens", + "moonbitlang/parser/basic", + "moonbitlang/parser/mbti_ast", + "moonbitlang/parser/syntax", + "moonbitlang/parser/attribute", +} + +options( + "pre-build": [ + { + "command": "$mod_dir/.mooncakes/moonbitlang/yacc/moonyacc --external-tokens --input-mode array $input -o $output && moonfmt -w $output && moonfmt -w $output", + "input": "mbti_parser.mbty", + "output": "mbti_parser.mbt", + }, + ], + "warn-list": "-6", +) \ No newline at end of file diff --git a/mbti_parser/moon.pkg.json b/mbti_parser/moon.pkg.json deleted file mode 100644 index 0e07d2df..00000000 --- a/mbti_parser/moon.pkg.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "pre-build": [ - { - "command": "$mod_dir/.mooncakes/moonbitlang/yacc/moonyacc --external-tokens --input-mode array $input -o $output && moonfmt -w $output && moonfmt -w $output", - "input": "mbti_parser.mbty", - "output": "mbti_parser.mbt" - } - ], - "import": [ - "moonbitlang/parser/tokens", - "moonbitlang/parser/basic", - "moonbitlang/parser/mbti_ast", - "moonbitlang/parser/syntax", - "moonbitlang/parser/attribute" - ], - "warn-list": "-6" -} diff --git a/moon.pkg b/moon.pkg new file mode 100644 index 00000000..7f257d52 --- /dev/null +++ b/moon.pkg @@ -0,0 +1,9 @@ +import { + "moonbitlang/parser/syntax", + "moonbitlang/parser/handrolled_parser", + "moonbitlang/parser/lexer", + "moonbitlang/parser/tokens", + "moonbitlang/x/fs", + "moonbitlang/parser/basic", + "moonbitlang/parser/yacc_parser", +} \ No newline at end of file diff --git a/moon.pkg.json b/moon.pkg.json deleted file mode 100644 index b3ea912f..00000000 --- a/moon.pkg.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "import": [ - "moonbitlang/parser/syntax", - "moonbitlang/parser/handrolled_parser", - "moonbitlang/parser/lexer", - "moonbitlang/parser/tokens", - "moonbitlang/x/fs", - "moonbitlang/parser/basic", - "moonbitlang/parser/yacc_parser" - ] -} \ No newline at end of file diff --git a/syntax/moon.pkg b/syntax/moon.pkg new file mode 100644 index 00000000..49e79fab --- /dev/null +++ b/syntax/moon.pkg @@ -0,0 +1,9 @@ +import { + "moonbitlang/parser/tokens", + "moonbitlang/parser/basic", + "moonbitlang/parser/attribute", +} + +options( + "warn-list": "-28", +) \ No newline at end of file diff --git a/syntax/moon.pkg.json b/syntax/moon.pkg.json deleted file mode 100644 index 3b187aea..00000000 --- a/syntax/moon.pkg.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "import": [ - "moonbitlang/parser/tokens", - "moonbitlang/parser/basic", - "moonbitlang/parser/attribute" - ], - "warn-list": "-28" -} \ No newline at end of file diff --git a/syntax/util/moon.pkg b/syntax/util/moon.pkg new file mode 100644 index 00000000..62b9283c --- /dev/null +++ b/syntax/util/moon.pkg @@ -0,0 +1,8 @@ +import { "moonbitlang/parser/syntax", "moonbitlang/parser/basic" } + +import "test" { } + +options( + "pre-build": [ ], + "warn-list": "-1-6", +) \ No newline at end of file diff --git a/syntax/util/moon.pkg.json b/syntax/util/moon.pkg.json deleted file mode 100644 index ebf6ba3c..00000000 --- a/syntax/util/moon.pkg.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "import": [ - "moonbitlang/parser/syntax", - "moonbitlang/parser/basic" - ], - "pre-build": [], - "test-import": [], - "warn-list": "-1-6" -} \ No newline at end of file diff --git a/test/manual_test/moon.pkg b/test/manual_test/moon.pkg new file mode 100644 index 00000000..08ec75e0 --- /dev/null +++ b/test/manual_test/moon.pkg @@ -0,0 +1,6 @@ +import "test" { + "moonbitlang/parser", + "moonbitlang/parser/syntax", + "moonbitlang/parser/basic", + "moonbitlang/x/fs", +} \ No newline at end of file diff --git a/test/manual_test/moon.pkg.json b/test/manual_test/moon.pkg.json deleted file mode 100644 index a30a6806..00000000 --- a/test/manual_test/moon.pkg.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "test-import": [ - "moonbitlang/parser", - "moonbitlang/parser/syntax", - "moonbitlang/parser/basic", - "moonbitlang/x/fs" - ] -} \ No newline at end of file diff --git a/test/mbti_parser_test/gen_test/moon.pkg b/test/mbti_parser_test/gen_test/moon.pkg new file mode 100644 index 00000000..679ce88e --- /dev/null +++ b/test/mbti_parser_test/gen_test/moon.pkg @@ -0,0 +1,5 @@ +import { "moonbitlang/x/fs" } + +options( + "is-main": true, +) \ No newline at end of file diff --git a/test/mbti_parser_test/gen_test/moon.pkg.json b/test/mbti_parser_test/gen_test/moon.pkg.json deleted file mode 100644 index 442e55df..00000000 --- a/test/mbti_parser_test/gen_test/moon.pkg.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "is-main": true, - "import": [ - "moonbitlang/x/fs" - ] -} \ No newline at end of file diff --git a/test/mbti_parser_test/moon.pkg b/test/mbti_parser_test/moon.pkg new file mode 100644 index 00000000..adfeb599 --- /dev/null +++ b/test/mbti_parser_test/moon.pkg @@ -0,0 +1,12 @@ +import "test" { + "moonbitlang/parser/tokens", + "moonbitlang/parser/basic", + "moonbitlang/parser/mbti_ast", + "moonbitlang/x/fs", + "moonbitlang/parser/lexer", + "moonbitlang/parser/mbti_parser", +} + +options( + "warn-list": "-6", +) \ No newline at end of file diff --git a/test/mbti_parser_test/moon.pkg.json b/test/mbti_parser_test/moon.pkg.json deleted file mode 100644 index 4b04af37..00000000 --- a/test/mbti_parser_test/moon.pkg.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "warn-list": "-6", - "test-import": [ - "moonbitlang/parser/tokens", - "moonbitlang/parser/basic", - "moonbitlang/parser/mbti_ast", - "moonbitlang/x/fs", - "moonbitlang/parser/lexer", - "moonbitlang/parser/mbti_parser" - ] -} \ No newline at end of file diff --git a/test/sync_test/generator/moon.pkg b/test/sync_test/generator/moon.pkg new file mode 100644 index 00000000..679ce88e --- /dev/null +++ b/test/sync_test/generator/moon.pkg @@ -0,0 +1,5 @@ +import { "moonbitlang/x/fs" } + +options( + "is-main": true, +) \ No newline at end of file diff --git a/test/sync_test/generator/moon.pkg.json b/test/sync_test/generator/moon.pkg.json deleted file mode 100644 index 442e55df..00000000 --- a/test/sync_test/generator/moon.pkg.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "is-main": true, - "import": [ - "moonbitlang/x/fs" - ] -} \ No newline at end of file diff --git a/test/sync_test/moon.pkg b/test/sync_test/moon.pkg new file mode 100644 index 00000000..01881450 --- /dev/null +++ b/test/sync_test/moon.pkg @@ -0,0 +1,8 @@ +import "test" { + "moonbitlang/parser", + "moonbitlang/parser/syntax", + "moonbitlang/parser/basic", + "moonbitlang/parser/lexer", + "moonbitlang/parser/tokens", + "moonbitlang/x/fs", +} \ No newline at end of file diff --git a/test/sync_test/moon.pkg.json b/test/sync_test/moon.pkg.json deleted file mode 100644 index c107a219..00000000 --- a/test/sync_test/moon.pkg.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "test-import": [ - "moonbitlang/parser", - "moonbitlang/parser/syntax", - "moonbitlang/parser/basic", - "moonbitlang/parser/lexer", - "moonbitlang/parser/tokens", - "moonbitlang/x/fs" - ] -} \ No newline at end of file diff --git a/tokens/moon.pkg.json b/tokens/moon.pkg similarity index 71% rename from tokens/moon.pkg.json rename to tokens/moon.pkg index 94851e88..595ad52a 100644 --- a/tokens/moon.pkg.json +++ b/tokens/moon.pkg @@ -1,12 +1,11 @@ -{ +import { "moonbitlang/parser/basic" } + +options( "pre-build": [ { "command": "$mod_dir/.mooncakes/moonbitlang/yacc/moonyacc --mode only-tokens $input -o $output && moonfmt -w $output && moonfmt -w $output", "input": "../yacc_parser/parser.mbty", - "output": "tokens.mbt" - } + "output": "tokens.mbt", + }, ], - "import": [ - "moonbitlang/parser/basic" - ] -} \ No newline at end of file +) \ No newline at end of file diff --git a/yacc_parser/moon.pkg b/yacc_parser/moon.pkg new file mode 100644 index 00000000..ac2f9c32 --- /dev/null +++ b/yacc_parser/moon.pkg @@ -0,0 +1,18 @@ +import { + "moonbitlang/parser/syntax", + "moonbitlang/parser/syntax/util", + "moonbitlang/parser/tokens", + "moonbitlang/parser/basic", + "moonbitlang/parser/attribute", +} + +options( + "pre-build": [ + { + "command": "$mod_dir/.mooncakes/moonbitlang/yacc/moonyacc --no-comments --external-tokens $input -o $output && moonfmt -w $output && moonfmt -w $output", + "input": "parser.mbty", + "output": "parser.mbt", + }, + ], + "warn-list": "-6", +) \ No newline at end of file diff --git a/yacc_parser/moon.pkg.json b/yacc_parser/moon.pkg.json deleted file mode 100644 index 38de69a3..00000000 --- a/yacc_parser/moon.pkg.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "import": [ - "moonbitlang/parser/syntax", - "moonbitlang/parser/syntax/util", - "moonbitlang/parser/tokens", - "moonbitlang/parser/basic", - "moonbitlang/parser/attribute" - ], - "pre-build": [ - { - "command": "$mod_dir/.mooncakes/moonbitlang/yacc/moonyacc --no-comments --external-tokens $input -o $output && moonfmt -w $output && moonfmt -w $output", - "input": "parser.mbty", - "output": "parser.mbt" - } - ], - "warn-list": "-6" -} \ No newline at end of file diff --git a/yacc_parser/parser.mbt b/yacc_parser/parser.mbt index a4bb24f8..77809c52 100644 --- a/yacc_parser/parser.mbt +++ b/yacc_parser/parser.mbt @@ -11,466 +11,714 @@ type YYObj = Error priv suberror YYObj_Void ///| -priv suberror YYObj_Int Int +priv suberror YYObj_Int { + YYObj_Int(Int) +} ///| -priv suberror YYObj_Var Var +priv suberror YYObj_Var { + YYObj_Var(Var) +} ///| -priv suberror YYObj_Bool Bool +priv suberror YYObj_Bool { + YYObj_Bool(Bool) +} ///| -priv suberror YYObj_Case Case +priv suberror YYObj_Case { + YYObj_Case(Case) +} ///| -priv suberror YYObj_Expr Expr +priv suberror YYObj_Expr { + YYObj_Expr(Expr) +} ///| -priv suberror YYObj_Func Func +priv suberror YYObj_Func { + YYObj_Func(Func) +} ///| -priv suberror YYObj_Impl Impl +priv suberror YYObj_Impl { + YYObj_Impl(Impl) +} ///| -priv suberror YYObj_List_Case_ List[Case] +priv suberror YYObj_List_Case_ { + YYObj_List_Case_(List[Case]) +} ///| -priv suberror YYObj_List_Expr_ List[Expr] +priv suberror YYObj_List_Expr_ { + YYObj_List_Expr_(List[Expr]) +} ///| -priv suberror YYObj_List_Impl_ List[Impl] +priv suberror YYObj_List_Impl_ { + YYObj_List_Impl_(List[Impl]) +} ///| -priv suberror YYObj_List_Type_ List[Type] +priv suberror YYObj_List_Type_ { + YYObj_List_Type_(List[Type]) +} ///| -priv suberror YYObj_List_String_ List[String] +priv suberror YYObj_List_String_ { + YYObj_List_String_(List[String]) +} ///| -priv suberror YYObj_List_LexCase_ List[LexCase] +priv suberror YYObj_List_LexCase_ { + YYObj_List_LexCase_(List[LexCase]) +} ///| -priv suberror YYObj_List_Pattern_ List[Pattern] +priv suberror YYObj_List_Pattern_ { + YYObj_List_Pattern_(List[Pattern]) +} ///| -priv suberror YYObj_List_Argument_ List[Argument] +priv suberror YYObj_List_Argument_ { + YYObj_List_Argument_(List[Argument]) +} ///| -priv suberror YYObj_List_FieldDef_ List[FieldDef] +priv suberror YYObj_List_FieldDef_ { + YYObj_List_FieldDef_(List[FieldDef]) +} ///| -priv suberror YYObj_List_FieldPat_ List[FieldPat] +priv suberror YYObj_List_FieldPat_ { + YYObj_List_FieldPat_(List[FieldPat]) +} ///| -priv suberror YYObj_List_Attribute_ List[Attribute] +priv suberror YYObj_List_Attribute_ { + YYObj_List_Attribute_(List[Attribute]) +} ///| -priv suberror YYObj_List_FieldDecl_ List[FieldDecl] +priv suberror YYObj_List_FieldDecl_ { + YYObj_List_FieldDecl_(List[FieldDecl]) +} ///| -priv suberror YYObj_List_Parameter_ List[Parameter] +priv suberror YYObj_List_Parameter_ { + YYObj_List_Parameter_(List[Parameter]) +} ///| -priv suberror YYObj_List_Statement_ List[Statement] +priv suberror YYObj_List_Statement_ { + YYObj_List_Statement_(List[Statement]) +} ///| -priv suberror YYObj_List_ConstrDecl_ List[ConstrDecl] +priv suberror YYObj_List_ConstrDecl_ { + YYObj_List_ConstrDecl_(List[ConstrDecl]) +} ///| -priv suberror YYObj_List_MapPatElem_ List[MapPatElem] +priv suberror YYObj_List_MapPatElem_ { + YYObj_List_MapPatElem_(List[MapPatElem]) +} ///| -priv suberror YYObj_List_AliasTarget_ List[AliasTarget] +priv suberror YYObj_List_AliasTarget_ { + YYObj_List_AliasTarget_(List[AliasTarget]) +} ///| -priv suberror YYObj_List_ConstrParam_ List[ConstrParam] +priv suberror YYObj_List_ConstrParam_ { + YYObj_List_ConstrParam_(List[ConstrParam]) +} ///| -priv suberror YYObj_List_MapExprElem_ List[MapExprElem] +priv suberror YYObj_List_MapExprElem_ { + YYObj_List_MapExprElem_(List[MapExprElem]) +} ///| -priv suberror YYObj_List_ArrayPattern_ List[ArrayPattern] +priv suberror YYObj_List_ArrayPattern_ { + YYObj_List_ArrayPattern_(List[ArrayPattern]) +} ///| -priv suberror YYObj_List_ArrowFnParam_ List[ArrowFnParam] +priv suberror YYObj_List_ArrowFnParam_ { + YYObj_List_ArrowFnParam_(List[ArrowFnParam]) +} ///| -priv suberror YYObj_List_ConstrPatArg_ List[ConstrPatArg] +priv suberror YYObj_List_ConstrPatArg_ { + YYObj_List_ConstrPatArg_(List[ConstrPatArg]) +} ///| -priv suberror YYObj_List_TypeVarBinder_ List[TypeVarBinder] +priv suberror YYObj_List_TypeVarBinder_ { + YYObj_List_TypeVarBinder_(List[TypeVarBinder]) +} ///| -priv suberror YYObj_List_SpreadableElem_ List[SpreadableElem] +priv suberror YYObj_List_SpreadableElem_ { + YYObj_List_SpreadableElem_(List[SpreadableElem]) +} ///| -priv suberror YYObj_List_TypeDeclBinder_ List[TypeDeclBinder] +priv suberror YYObj_List_TypeDeclBinder_ { + YYObj_List_TypeDeclBinder_(List[TypeDeclBinder]) +} ///| -priv suberror YYObj_List_TraitMethodDecl_ List[TraitMethodDecl] +priv suberror YYObj_List_TraitMethodDecl_ { + YYObj_List_TraitMethodDecl_(List[TraitMethodDecl]) +} ///| -priv suberror YYObj_List_DerivingDirective_ List[DerivingDirective] +priv suberror YYObj_List_DerivingDirective_ { + YYObj_List_DerivingDirective_(List[DerivingDirective]) +} ///| -priv suberror YYObj_List_MultilineStringElem_ List[MultilineStringElem] +priv suberror YYObj_List_MultilineStringElem_ { + YYObj_List_MultilineStringElem_(List[MultilineStringElem]) +} ///| -priv suberror YYObj_List_Binder__ List[Binder?] +priv suberror YYObj_List_Binder__ { + YYObj_List_Binder__(List[Binder?]) +} ///| -priv suberror YYObj_List__Binder__Expr__ List[(Binder, Expr)] +priv suberror YYObj_List__Binder__Expr__ { + YYObj_List__Binder__Expr__(List[(Binder, Expr)]) +} ///| -priv suberror YYObj_List__AliasTarget__UsingKind__ List[ - (AliasTarget, UsingKind), -] +priv suberror YYObj_List__AliasTarget__UsingKind__ { + YYObj_List__AliasTarget__UsingKind__(List[(AliasTarget, UsingKind)]) +} ///| -priv suberror YYObj_List__ArrowFnParam__Type___ List[(ArrowFnParam, Type?)] +priv suberror YYObj_List__ArrowFnParam__Type___ { + YYObj_List__ArrowFnParam__Type___(List[(ArrowFnParam, Type?)]) +} ///| -priv suberror YYObj_Type Type +priv suberror YYObj_Type { + YYObj_Type(Type) +} ///| -priv suberror YYObj_Label Label +priv suberror YYObj_Label { + YYObj_Label(Label) +} ///| -priv suberror YYObj_Binder Binder +priv suberror YYObj_Binder { + YYObj_Binder(Binder) +} ///| -priv suberror YYObj_Option_Bool_ Bool? +priv suberror YYObj_Option_Bool_ { + YYObj_Option_Bool_(Bool?) +} ///| -priv suberror YYObj_Option_Expr_ Expr? +priv suberror YYObj_Option_Expr_ { + YYObj_Option_Expr_(Expr?) +} ///| -priv suberror YYObj_Option_List_Type__ List[Type]? +priv suberror YYObj_Option_List_Type__ { + YYObj_Option_List_Type__(List[Type]?) +} ///| -priv suberror YYObj_Option_List_Parameter__ List[Parameter]? +priv suberror YYObj_Option_List_Parameter__ { + YYObj_Option_List_Parameter__(List[Parameter]?) +} ///| -priv suberror YYObj_Option_List_ConstrParam__ List[ConstrParam]? +priv suberror YYObj_Option_List_ConstrParam__ { + YYObj_Option_List_ConstrParam__(List[ConstrParam]?) +} ///| -priv suberror YYObj_Option_List_TypeVarBinder__ List[TypeVarBinder]? +priv suberror YYObj_Option_List_TypeVarBinder__ { + YYObj_Option_List_TypeVarBinder__(List[TypeVarBinder]?) +} ///| -priv suberror YYObj_Option_List_TypeDeclBinder__ List[TypeDeclBinder]? +priv suberror YYObj_Option_List_TypeDeclBinder__ { + YYObj_Option_List_TypeDeclBinder__(List[TypeDeclBinder]?) +} ///| -priv suberror YYObj_Option_Type_ Type? +priv suberror YYObj_Option_Type_ { + YYObj_Option_Type_(Type?) +} ///| -priv suberror YYObj_Option_Unit_ Unit? +priv suberror YYObj_Option_Unit_ { + YYObj_Option_Unit_(Unit?) +} ///| -priv suberror YYObj_Option_Label_ Label? +priv suberror YYObj_Option_Label_ { + YYObj_Option_Label_(Label?) +} ///| -priv suberror YYObj_Option_Binder_ Binder? +priv suberror YYObj_Option_Binder_ { + YYObj_Option_Binder_(Binder?) +} ///| -priv suberror YYObj_Option_Location_ Location? +priv suberror YYObj_Option_Location_ { + YYObj_Option_Location_(Location?) +} ///| -priv suberror YYObj_Option_TypeName_ TypeName? +priv suberror YYObj_Option_TypeName_ { + YYObj_Option_TypeName_(TypeName?) +} ///| -priv suberror YYObj_Option__list_List_TypeVarConstraint__ @list.List[ - TypeVarConstraint, -]? +priv suberror YYObj_Option__list_List_TypeVarConstraint__ { + YYObj_Option__list_List_TypeVarConstraint__(@list.List[TypeVarConstraint]?) +} ///| -priv suberror YYObj_Option__List_ConstrPatArg___Bool__ ( - List[ConstrPatArg], - Bool, -)? +priv suberror YYObj_Option__List_ConstrPatArg___Bool__ { + YYObj_Option__List_ConstrPatArg___Bool__((List[ConstrPatArg], Bool)?) +} ///| -priv suberror YYObj_Option__String__Location__ (String, Location)? +priv suberror YYObj_Option__String__Location__ { + YYObj_Option__String__Location__((String, Location)?) +} ///| -priv suberror YYObj_Option__StringLiteral__Location__ (StringLiteral, Location)? +priv suberror YYObj_Option__StringLiteral__Location__ { + YYObj_Option__StringLiteral__Location__((StringLiteral, Location)?) +} ///| -priv suberror YYObj_String String +priv suberror YYObj_String { + YYObj_String(String) +} ///| -priv suberror YYObj_Comment Comment +priv suberror YYObj_Comment { + YYObj_Comment(Comment) +} ///| -priv suberror YYObj_FunDecl FunDecl +priv suberror YYObj_FunDecl { + YYObj_FunDecl(FunDecl) +} ///| -priv suberror YYObj_LexCase LexCase +priv suberror YYObj_LexCase { + YYObj_LexCase(LexCase) +} ///| -priv suberror YYObj_Pattern Pattern +priv suberror YYObj_Pattern { + YYObj_Pattern(Pattern) +} ///| -priv suberror YYObj_Accessor Accessor +priv suberror YYObj_Accessor { + YYObj_Accessor(Accessor) +} ///| -priv suberror YYObj_Argument Argument +priv suberror YYObj_Argument { + YYObj_Argument(Argument) +} ///| -priv suberror YYObj_Constant Constant +priv suberror YYObj_Constant { + YYObj_Constant(Constant) +} ///| -priv suberror YYObj_DeclBody DeclBody +priv suberror YYObj_DeclBody { + YYObj_DeclBody(DeclBody) +} ///| -priv suberror YYObj_FieldDef FieldDef +priv suberror YYObj_FieldDef { + YYObj_FieldDef(FieldDef) +} ///| -priv suberror YYObj_FieldPat FieldPat +priv suberror YYObj_FieldPat { + YYObj_FieldPat(FieldPat) +} ///| -priv suberror YYObj_Location Location +priv suberror YYObj_Location { + YYObj_Location(Location) +} ///| -priv suberror YYObj_TypeName TypeName +priv suberror YYObj_TypeName { + YYObj_TypeName(TypeName) +} ///| -priv suberror YYObj_ApplyAttr ApplyAttr +priv suberror YYObj_ApplyAttr { + YYObj_ApplyAttr(ApplyAttr) +} ///| -priv suberror YYObj_Attribute Attribute +priv suberror YYObj_Attribute { + YYObj_Attribute(Attribute) +} ///| -priv suberror YYObj_ErrorType ErrorType +priv suberror YYObj_ErrorType { + YYObj_ErrorType(ErrorType) +} ///| -priv suberror YYObj_FieldDecl FieldDecl +priv suberror YYObj_FieldDecl { + YYObj_FieldDecl(FieldDecl) +} ///| -priv suberror YYObj_LeftValue LeftValue +priv suberror YYObj_LeftValue { + YYObj_LeftValue(LeftValue) +} ///| -priv suberror YYObj_LongIdent LongIdent +priv suberror YYObj_LongIdent { + YYObj_LongIdent(LongIdent) +} ///| -priv suberror YYObj_Parameter Parameter +priv suberror YYObj_Parameter { + YYObj_Parameter(Parameter) +} ///| -priv suberror YYObj_Statement Statement +priv suberror YYObj_Statement { + YYObj_Statement(Statement) +} ///| -priv suberror YYObj_ConstrDecl ConstrDecl +priv suberror YYObj_ConstrDecl { + YYObj_ConstrDecl(ConstrDecl) +} ///| -priv suberror YYObj_LexPattern LexPattern +priv suberror YYObj_LexPattern { + YYObj_LexPattern(LexPattern) +} ///| -priv suberror YYObj_MapPatElem MapPatElem +priv suberror YYObj_MapPatElem { + YYObj_MapPatElem(MapPatElem) +} ///| -priv suberror YYObj_Visibility Visibility +priv suberror YYObj_Visibility { + YYObj_Visibility(Visibility) +} ///| -priv suberror YYObj_AliasTarget AliasTarget +priv suberror YYObj_AliasTarget { + YYObj_AliasTarget(AliasTarget) +} ///| -priv suberror YYObj_CharLiteral CharLiteral +priv suberror YYObj_CharLiteral { + YYObj_CharLiteral(CharLiteral) +} ///| -priv suberror YYObj_ConstrParam ConstrParam +priv suberror YYObj_ConstrParam { + YYObj_ConstrParam(ConstrParam) +} ///| -priv suberror YYObj_Constructor Constructor +priv suberror YYObj_Constructor { + YYObj_Constructor(Constructor) +} ///| -priv suberror YYObj_MapExprElem MapExprElem +priv suberror YYObj_MapExprElem { + YYObj_MapExprElem(MapExprElem) +} ///| -priv suberror YYObj_ArrayPattern ArrayPattern +priv suberror YYObj_ArrayPattern { + YYObj_ArrayPattern(ArrayPattern) +} ///| -priv suberror YYObj_ConstrPatArg ConstrPatArg +priv suberror YYObj_ConstrPatArg { + YYObj_ConstrPatArg(ConstrPatArg) +} ///| -priv suberror YYObj_DotDotBinder DotDotBinder +priv suberror YYObj_DotDotBinder { + YYObj_DotDotBinder(DotDotBinder) +} ///| -priv suberror YYObj_ArrayPatterns ArrayPatterns +priv suberror YYObj_ArrayPatterns { + YYObj_ArrayPatterns(ArrayPatterns) +} ///| -priv suberror YYObj_InterpLiteral InterpLiteral +priv suberror YYObj_InterpLiteral { + YYObj_InterpLiteral(InterpLiteral) +} ///| -priv suberror YYObj_LexTopPattern LexTopPattern +priv suberror YYObj_LexTopPattern { + YYObj_LexTopPattern(LexTopPattern) +} ///| -priv suberror YYObj_LocalTypeDecl LocalTypeDecl +priv suberror YYObj_LocalTypeDecl { + YYObj_LocalTypeDecl(LocalTypeDecl) +} ///| -priv suberror YYObj_StringLiteral StringLiteral +priv suberror YYObj_StringLiteral { + YYObj_StringLiteral(StringLiteral) +} ///| -priv suberror YYObj_TypeVarBinder TypeVarBinder +priv suberror YYObj_TypeVarBinder { + YYObj_TypeVarBinder(TypeVarBinder) +} ///| -priv suberror YYObj_SpreadableElem SpreadableElem +priv suberror YYObj_SpreadableElem { + YYObj_SpreadableElem(SpreadableElem) +} ///| -priv suberror YYObj_TypeDeclBinder TypeDeclBinder +priv suberror YYObj_TypeDeclBinder { + YYObj_TypeDeclBinder(TypeDeclBinder) +} ///| -priv suberror YYObj_TraitMethodDecl TraitMethodDecl +priv suberror YYObj_TraitMethodDecl { + YYObj_TraitMethodDecl(TraitMethodDecl) +} ///| -priv suberror YYObj_DerivingDirective DerivingDirective +priv suberror YYObj_DerivingDirective { + YYObj_DerivingDirective(DerivingDirective) +} ///| -priv suberror YYObj_TypeVarConstraint TypeVarConstraint +priv suberror YYObj_TypeVarConstraint { + YYObj_TypeVarConstraint(TypeVarConstraint) +} ///| -priv suberror YYObj_MultilineStringElem MultilineStringElem +priv suberror YYObj_MultilineStringElem { + YYObj_MultilineStringElem(MultilineStringElem) +} ///| -priv suberror YYObj__list_List_LexPattern_ @list.List[LexPattern] +priv suberror YYObj__list_List_LexPattern_ { + YYObj__list_List_LexPattern_(@list.List[LexPattern]) +} ///| -priv suberror YYObj__list_List_LexTopPattern_ @list.List[LexTopPattern] +priv suberror YYObj__list_List_LexTopPattern_ { + YYObj__list_List_LexTopPattern_(@list.List[LexTopPattern]) +} ///| -priv suberror YYObj__list_List_TypeVarConstraint_ @list.List[TypeVarConstraint] +priv suberror YYObj__list_List_TypeVarConstraint_ { + YYObj__list_List_TypeVarConstraint_(@list.List[TypeVarConstraint]) +} ///| -priv suberror YYObj__list_List__Binder__Type___Func__ @list.List[ - (Binder, Type?, Func), -] +priv suberror YYObj__list_List__Binder__Type___Func__ { + YYObj__list_List__Binder__Type___Func__(@list.List[(Binder, Type?, Func)]) +} ///| -priv suberror YYObj_Expr_ Expr? +priv suberror YYObj_Expr_ { + YYObj_Expr_(Expr?) +} ///| -priv suberror YYObj_Type_ Type? +priv suberror YYObj_Type_ { + YYObj_Type_(Type?) +} ///| -priv suberror YYObj_Label_ Label? +priv suberror YYObj_Label_ { + YYObj_Label_(Label?) +} ///| -priv suberror YYObj_Binder_ Binder? +priv suberror YYObj_Binder_ { + YYObj_Binder_(Binder?) +} ///| -priv suberror YYObj_String_ String? +priv suberror YYObj_String_ { + YYObj_String_(String?) +} ///| -priv suberror YYObj_Location_ Location? +priv suberror YYObj_Location_ { + YYObj_Location_(Location?) +} ///| -priv suberror YYObj__Bool__Location_ (Bool, Location) +priv suberror YYObj__Bool__Location_ { + YYObj__Bool__Location_((Bool, Location)) +} ///| -priv suberror YYObj__Expr__Bool_ (Expr, Bool) +priv suberror YYObj__Expr__Bool_ { + YYObj__Expr__Bool_((Expr, Bool)) +} ///| -priv suberror YYObj__Expr__Label__ (Expr, Label?) +priv suberror YYObj__Expr__Label__ { + YYObj__Expr__Label__((Expr, Label?)) +} ///| -priv suberror YYObj__List_FieldDef___Bool_ (List[FieldDef], Bool) +priv suberror YYObj__List_FieldDef___Bool_ { + YYObj__List_FieldDef___Bool_((List[FieldDef], Bool)) +} ///| -priv suberror YYObj__List_FieldDef___TrailingMark_ ( - List[FieldDef], - TrailingMark, -) +priv suberror YYObj__List_FieldDef___TrailingMark_ { + YYObj__List_FieldDef___TrailingMark_((List[FieldDef], TrailingMark)) +} ///| -priv suberror YYObj__List_FieldPat___Bool_ (List[FieldPat], Bool) +priv suberror YYObj__List_FieldPat___Bool_ { + YYObj__List_FieldPat___Bool_((List[FieldPat], Bool)) +} ///| -priv suberror YYObj__List_Statement___Bool_ (List[Statement], Bool) +priv suberror YYObj__List_Statement___Bool_ { + YYObj__List_Statement___Bool_((List[Statement], Bool)) +} ///| -priv suberror YYObj__List_MapPatElem___Bool_ (List[MapPatElem], Bool) +priv suberror YYObj__List_MapPatElem___Bool_ { + YYObj__List_MapPatElem___Bool_((List[MapPatElem], Bool)) +} ///| -priv suberror YYObj__List_ConstrPatArg___Bool_ (List[ConstrPatArg], Bool) +priv suberror YYObj__List_ConstrPatArg___Bool_ { + YYObj__List_ConstrPatArg___Bool_((List[ConstrPatArg], Bool)) +} ///| -priv suberror YYObj__List_LocalTypeDecl___Expr_ (List[LocalTypeDecl], Expr) +priv suberror YYObj__List_LocalTypeDecl___Expr_ { + YYObj__List_LocalTypeDecl___Expr_((List[LocalTypeDecl], Expr)) +} ///| -priv suberror YYObj__Type__ErrorType_ (Type, ErrorType) +priv suberror YYObj__Type__ErrorType_ { + YYObj__Type__ErrorType_((Type, ErrorType)) +} ///| -priv suberror YYObj__Binder__Expr_ (Binder, Expr) +priv suberror YYObj__Binder__Expr_ { + YYObj__Binder__Expr_((Binder, Expr)) +} ///| -priv suberror YYObj__String__Location_ (String, Location) +priv suberror YYObj__String__Location_ { + YYObj__String__Location_((String, Location)) +} ///| -priv suberror YYObj__AliasTarget__UsingKind_ (AliasTarget, UsingKind) +priv suberror YYObj__AliasTarget__UsingKind_ { + YYObj__AliasTarget__UsingKind_((AliasTarget, UsingKind)) +} ///| -priv suberror YYObj__StringLiteral__FunDecl_ (StringLiteral, FunDecl) +priv suberror YYObj__StringLiteral__FunDecl_ { + YYObj__StringLiteral__FunDecl_((StringLiteral, FunDecl)) +} ///| -priv suberror YYObj__StringLiteral__Location_ (StringLiteral, Location) +priv suberror YYObj__StringLiteral__Location_ { + YYObj__StringLiteral__Location_((StringLiteral, Location)) +} ///| -priv suberror YYObj__Type___ErrorType_ (Type?, ErrorType) +priv suberror YYObj__Type___ErrorType_ { + YYObj__Type___ErrorType_((Type?, ErrorType)) +} ///| -priv suberror YYObj__TypeName___Binder_ (TypeName?, Binder) +priv suberror YYObj__TypeName___Binder_ { + YYObj__TypeName___Binder_((TypeName?, Binder)) +} ///| -priv suberror YYObj__Bool__Label___List_AliasTarget__ ( - Bool, - Label?, - List[AliasTarget], -) +priv suberror YYObj__Bool__Label___List_AliasTarget__ { + YYObj__Bool__Label___List_AliasTarget__((Bool, Label?, List[AliasTarget])) +} ///| -priv suberror YYObj__Binder__Type___Func_ (Binder, Type?, Func) +priv suberror YYObj__Binder__Type___Func_ { + YYObj__Binder__Type___Func_((Binder, Type?, Func)) +} ///| -priv suberror YYObj__String__String___String_ (String, String?, String) +priv suberror YYObj__String__String___String_ { + YYObj__String__String___String_((String, String?, String)) +} ///| -priv suberror YYObj___TypeName___Binder___Location___List_TypeVarBinder__ ( - (TypeName?, Binder), - Location?, - List[TypeVarBinder], -) +priv suberror YYObj___TypeName___Binder___Location___List_TypeVarBinder__ { + YYObj___TypeName___Binder___Location___List_TypeVarBinder__( + ((TypeName?, Binder), Location?, List[TypeVarBinder]) + ) +} ///| -priv suberror YYObj__List_Attribute___Visibility__String__Location_ ( - List[Attribute], - Visibility, - String, - Location, -) +priv suberror YYObj__List_Attribute___Visibility__String__Location_ { + YYObj__List_Attribute___Visibility__String__Location_( + (List[Attribute], Visibility, String, Location) + ) +} ///| -priv suberror YYObj__Label___Label___Bool__List_AliasTarget__ ( - Label?, - Label?, - Bool, - List[AliasTarget], -) +priv suberror YYObj__Label___Label___Bool__List_AliasTarget__ { + YYObj__Label___Label___Bool__List_AliasTarget__( + (Label?, Label?, Bool, List[AliasTarget]) + ) +} ///| -priv suberror YYObj__List_Attribute___Bool__Visibility__Binder__Type__ ( - List[Attribute], - Bool, - Visibility, - Binder, - Type?, -) +priv suberror YYObj__List_Attribute___Bool__Visibility__Binder__Type__ { + YYObj__List_Attribute___Bool__Visibility__Binder__Type__( + (List[Attribute], Bool, Visibility, Binder, Type?) + ) +} ///| -priv suberror YYObj__List_Attribute___Visibility__String__Location__List_TypeDeclBinder__ ( - List[Attribute], - Visibility, - String, - Location, - List[TypeDeclBinder], -) +priv suberror YYObj__List_Attribute___Visibility__String__Location__List_TypeDeclBinder__ { + YYObj__List_Attribute___Visibility__String__Location__List_TypeDeclBinder__( + (List[Attribute], Visibility, String, Location, List[TypeDeclBinder]) + ) +} ///| type YYState = (YYSymbol) -> YYDecision From 9a769572bae7d8969308d6fb1b5bfe1e14c32deb Mon Sep 17 00:00:00 2001 From: myfreess Date: Sun, 11 Jan 2026 19:20:39 +0800 Subject: [PATCH 2/2] expose two json_repr method --- syntax/ast_json_repr.mbt | 12 ++---------- syntax/pkg.generated.mbti | 4 ++-- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/syntax/ast_json_repr.mbt b/syntax/ast_json_repr.mbt index 59467629..6bb05a2f 100644 --- a/syntax/ast_json_repr.mbt +++ b/syntax/ast_json_repr.mbt @@ -314,7 +314,7 @@ fn FieldName::json_repr(self : FieldName) -> Json { } ///| -fn Expr::json_repr(self : Expr) -> Json { +pub fn Expr::json_repr(self : Expr) -> Json { match self { Apply(func~, args~, attr~, loc~) => { let args_list = list_json_repr( @@ -1552,7 +1552,7 @@ fn raise_json_repr(loc : Location) -> Json { } ///| -fn Impl::json_repr(self : Impl) -> Json { +pub fn Impl::json_repr(self : Impl) -> Json { match self { TopExpr(expr~, is_main~, local_types~, is_async~, loc~) => tagged_node("Impl::TopExpr", loc, { @@ -1802,11 +1802,3 @@ fn Impl::json_repr(self : Impl) -> Json { }) } } - -///| -/// -pub fn impls_json_repr(lst : Impls) -> Json { - let impls = [] - lst.each(impl_ => impls.push(impl_.json_repr())) - Json::array(impls) -} diff --git a/syntax/pkg.generated.mbti b/syntax/pkg.generated.mbti index 36d8f600..c7a17faa 100644 --- a/syntax/pkg.generated.mbti +++ b/syntax/pkg.generated.mbti @@ -21,8 +21,6 @@ pub fn desugar_array_get(loc~ : @basic.Location, Expr, Expr) -> Expr pub fn desugar_array_set(loc~ : @basic.Location, Expr, Expr, Expr) -> Expr -pub fn impls_json_repr(@list.List[Impl]) -> Json - pub fn impls_to_json(@list.List[Impl]) -> Json pub fn label_to_expr(loc~ : @basic.Location, Label) -> Expr @@ -323,6 +321,7 @@ pub(all) enum Expr { Group(expr~ : Expr, group~ : Group, loc~ : @basic.Location) StaticAssert(asserts~ : @list.List[StaticAssertion], body~ : Expr) } +pub fn Expr::json_repr(Self) -> Json pub fn Expr::loc(Self) -> @basic.Location pub impl ToJson for Expr @@ -428,6 +427,7 @@ pub(all) enum Impl { TopImplRelation(self_ty~ : Type, trait_~ : TypeName, quantifiers~ : @list.List[TypeVarBinder], vis~ : Visibility, attrs~ : @list.List[@attribute.Attribute], loc~ : @basic.Location, mut doc~ : DocString) TopUsing(pkg~ : Label, names~ : @list.List[(AliasTarget, UsingKind)], vis~ : Visibility, attrs~ : @list.List[@attribute.Attribute], loc~ : @basic.Location, mut doc~ : DocString) } +pub fn Impl::json_repr(Self) -> Json pub fn Impl::loc(Self) -> @basic.Location pub impl ToJson for Impl