Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions attribute/pkg.generated.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub suberror ParseError {
UnexpectedToken(@tokens.Token, (@basic.Position, @basic.Position), Array[@tokens.TokenKind])
UnexpectedEndOfInput(@basic.Position, Array[@tokens.TokenKind])
} derive(@debug.Debug)
pub fn ParseError::to_repr(Self) -> @debug.Repr

// Types and methods
pub(all) struct Attribute {
Expand All @@ -25,6 +26,8 @@ pub(all) struct Attribute {
} derive(@debug.Debug)
pub fn Attribute::name(Self) -> String?
pub fn Attribute::new(loc~ : @basic.Location, (String, String?, String)) -> Self
pub fn Attribute::to_json(Self) -> Json
pub fn Attribute::to_repr(Self) -> @debug.Repr
pub impl ToJson for Attribute

pub(all) enum Expr {
Expand All @@ -33,18 +36,23 @@ pub(all) enum Expr {
Apply(Id, @list.List[Prop])
Bool(Bool)
} derive(@debug.Debug)
pub fn Expr::to_repr(Self) -> @debug.Repr

pub(all) struct Id {
qual : String?
name : String
}
pub fn Id::output(Self, &Logger) -> Unit
pub fn Id::to_repr(Self) -> @debug.Repr
pub fn Id::to_string(Self) -> String
pub impl Show for Id
pub impl @debug.Debug for Id

pub(all) enum Prop {
Labeled(String, Expr)
Expr(Expr)
} derive(@debug.Debug)
pub fn Prop::to_repr(Self) -> @debug.Repr

// Type aliases

Expand Down
20 changes: 20 additions & 0 deletions attribute/trait_extensions.mbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
///|
pub extend Id with Show::{to_string, output}

///|
pub extend Id with @moonbitlang/core/debug.Debug::{to_repr}

///|
pub extend Expr with @moonbitlang/core/debug.Debug::{to_repr}

///|
pub extend Prop with @moonbitlang/core/debug.Debug::{to_repr}

///|
pub extend Attribute with @moonbitlang/core/debug.Debug::{to_repr}

///|
pub extend Attribute with ToJson::{to_json}

///|
pub extend ParseError with @moonbitlang/core/debug.Debug::{to_repr}
18 changes: 18 additions & 0 deletions fmt/internal/comment/pkg.generated.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,17 @@ pub(all) struct Comment {
right : (@tokens.Token, @basic.Position, @basic.Position)?
kind : CommentKind
} derive(@debug.Debug)
pub fn Comment::pretty(Self) -> @prettyprinter.Document
pub fn Comment::to_repr(Self) -> @debug.Repr
pub impl @prettyprinter.Pretty for Comment

pub(all) enum CommentKind {
Blank
Block(String)
Line(String)
} derive(@debug.Debug)
pub fn CommentKind::pretty(Self) -> @prettyprinter.Document
pub fn CommentKind::to_repr(Self) -> @debug.Repr
pub impl @prettyprinter.Pretty for CommentKind

pub struct CommentSlot {
Expand All @@ -66,7 +70,17 @@ pub(all) enum Key {
Token(@basic.Location)
Node(@basic.Location)
} derive(Compare, Eq, Hash)
pub fn Key::compare(Self, Self) -> Int
pub fn Key::equal(Self, Self) -> Bool
pub fn Key::hash(Self) -> Int
pub fn Key::hash_combine(Self, Hasher) -> Unit
pub fn Key::loc(Self) -> @basic.Location
pub fn Key::not_equal(Self, Self) -> Bool
pub fn Key::op_ge(Self, Self) -> Bool
pub fn Key::op_gt(Self, Self) -> Bool
pub fn Key::op_le(Self, Self) -> Bool
pub fn Key::op_lt(Self, Self) -> Bool
pub fn Key::pretty(Self) -> @prettyprinter.Document
pub impl @prettyprinter.Pretty for Key

type Mapper
Expand All @@ -83,6 +97,7 @@ pub fn NodeArray::empty() -> Self
#alias("_[_]")
pub fn NodeArray::get(Self, Int) -> Key?
pub fn NodeArray::last(Self) -> Key?
pub fn NodeArray::pretty(Self) -> @prettyprinter.Document
pub impl @prettyprinter.Pretty for NodeArray

type NodeTable
Expand All @@ -92,15 +107,18 @@ pub fn NodeTable::get_table(Self, String) -> Self
pub fn NodeTable::get_table_array(Self, String) -> NodeTableArray
pub fn NodeTable::get_token(Self, String) -> Key?
pub fn NodeTable::new(Map[String, TokenGroup]) -> Self
pub fn NodeTable::pretty(Self) -> @prettyprinter.Document
pub impl @prettyprinter.Pretty for NodeTable

type NodeTableArray
pub fn NodeTableArray::empty() -> Self
#alias("_[_]")
pub fn NodeTableArray::get(Self, Int) -> NodeTable
pub fn NodeTableArray::pretty(Self) -> @prettyprinter.Document
pub impl @prettyprinter.Pretty for NodeTableArray

type TokenGroup
pub fn TokenGroup::pretty(Self) -> @prettyprinter.Document
pub impl @prettyprinter.Pretty for TokenGroup

// Type aliases
Expand Down
35 changes: 35 additions & 0 deletions fmt/internal/comment/trait_extensions.mbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
///|
pub extend Comment with Debug::{to_repr}

///|
pub extend Comment with @moonbit-community/prettyprinter.Pretty::{pretty}

///|
pub extend CommentKind with Debug::{to_repr}

///|
pub extend CommentKind with @moonbit-community/prettyprinter.Pretty::{pretty}

///|
pub extend NodeArray with @moonbit-community/prettyprinter.Pretty::{pretty}

///|
pub extend NodeTable with @moonbit-community/prettyprinter.Pretty::{pretty}

///|
pub extend TokenGroup with @moonbit-community/prettyprinter.Pretty::{pretty}

///|
pub extend Key with Eq::{not_equal, equal}

///|
pub extend Key with Hash::{hash, hash_combine}

///|
pub extend Key with Compare::{op_lt, op_le, op_ge, compare, op_gt}

///|
pub extend Key with @moonbit-community/prettyprinter.Pretty::{pretty}

///|
pub extend NodeTableArray with @moonbit-community/prettyprinter.Pretty::{pretty}
18 changes: 18 additions & 0 deletions mbti_ast/pkg.generated.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ pub(all) enum AliasSig {
Using(pkg~ : Name, target~ : Name, name~ : Name?, kind~ : @syntax.UsingKind, attrs~ : @list.List[@attribute.Attribute])
FuncAlias(name~ : Name, type_name~ : Name, attrs~ : @list.List[@attribute.Attribute])
} derive(@debug.Debug)
pub fn AliasSig::to_repr(Self) -> @debug.Repr

pub(all) struct ConstSig {
name : Name
type_ : @syntax.Type
value : @syntax.Constant
attrs : @list.List[@attribute.Attribute]
} derive(@debug.Debug)
pub fn ConstSig::to_repr(Self) -> @debug.Repr

pub(all) struct FuncSig {
attrs : @list.List[@attribute.Attribute]
Expand All @@ -36,13 +38,15 @@ pub(all) struct FuncSig {
type_params : @list.List[TypeParamWithConstraints]
is_async : @basic.Location?
} derive(@debug.Debug)
pub fn FuncSig::to_repr(Self) -> @debug.Repr

pub(all) struct ImplSig {
type_params : @list.List[TypeParamWithConstraints]
type_ : @syntax.Type
trait_name : QualifiedName
attrs : @list.List[@attribute.Attribute]
} derive(@debug.Debug)
pub fn ImplSig::to_repr(Self) -> @debug.Repr

pub(all) struct Mbti {
package_name : String
Expand All @@ -51,27 +55,33 @@ pub(all) struct Mbti {
loc : @basic.Location
base_pos : @basic.BasePos
} derive(@debug.Debug)
pub fn Mbti::to_repr(Self) -> @debug.Repr

pub(all) struct MethodSelfType {
name : String
is_object : Bool
loc : @basic.Location
} derive(@debug.Debug)
pub fn MethodSelfType::to_repr(Self) -> @debug.Repr

pub(all) struct Name {
name : String
loc : @basic.Location
} derive(ToJson, @debug.Debug)
pub fn Name::to_json(Self) -> Json
pub fn Name::to_repr(Self) -> @debug.Repr

pub(all) struct PackageImport {
name : String
alias_ : String?
} derive(@debug.Debug)
pub fn PackageImport::to_repr(Self) -> @debug.Repr

pub(all) struct QualifiedName {
name : @syntax.LongIdent
loc : @basic.Location
} derive(@debug.Debug)
pub fn QualifiedName::to_repr(Self) -> @debug.Repr

pub(all) enum Sig {
Func(FuncSig)
Expand All @@ -83,6 +93,7 @@ pub(all) enum Sig {
Value(ValueSig)
} derive(@debug.Debug)
pub fn Sig::attrs(Self) -> @list.List[@attribute.Attribute]
pub fn Sig::to_repr(Self) -> @debug.Repr

pub(all) struct TraitMethodSig {
name : Name
Expand All @@ -93,6 +104,7 @@ pub(all) struct TraitMethodSig {
return_ : (@syntax.Type, @syntax.ErrorType)
attrs : @list.List[@attribute.Attribute]
} derive(@debug.Debug)
pub fn TraitMethodSig::to_repr(Self) -> @debug.Repr

pub(all) struct TraitSig {
name : Name
Expand All @@ -101,6 +113,7 @@ pub(all) struct TraitSig {
vis : @syntax.Visibility
attrs : @list.List[@attribute.Attribute]
} derive(@debug.Debug)
pub fn TraitSig::to_repr(Self) -> @debug.Repr

pub(all) enum TypeDefinition {
Abstract
Expand All @@ -113,16 +126,19 @@ pub(all) enum TypeDefinition {
Record(fields~ : @list.List[@syntax.FieldDecl])
Alias(@syntax.Type)
} derive(@debug.Debug)
pub fn TypeDefinition::to_repr(Self) -> @debug.Repr

pub(all) enum TypeParamNoConstraints {
Name(Name)
Underscore(@basic.Location)
} derive(@debug.Debug)
pub fn TypeParamNoConstraints::to_repr(Self) -> @debug.Repr

pub(all) struct TypeParamWithConstraints {
name : Name
constraints : @list.List[QualifiedName]
} derive(@debug.Debug)
pub fn TypeParamWithConstraints::to_repr(Self) -> @debug.Repr

pub(all) struct TypeSig {
name : Name
Expand All @@ -132,12 +148,14 @@ pub(all) struct TypeSig {
attrs : @list.List[@attribute.Attribute]
derives : @list.List[QualifiedName]
} derive(@debug.Debug)
pub fn TypeSig::to_repr(Self) -> @debug.Repr

pub(all) struct ValueSig {
name : Name
type_ : @syntax.Type
attrs : @list.List[@attribute.Attribute]
} derive(@debug.Debug)
pub fn ValueSig::to_repr(Self) -> @debug.Repr

// Type aliases
pub type Attributes = @list.List[@attribute.Attribute]
Expand Down
53 changes: 53 additions & 0 deletions mbti_ast/trait_extensions.mbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
///|
pub extend Name with Debug::{to_repr}

///|
pub extend Name with ToJson::{to_json}

///|
pub extend QualifiedName with Debug::{to_repr}

///|
pub extend TypeParamWithConstraints with Debug::{to_repr}

///|
pub extend TypeParamNoConstraints with Debug::{to_repr}

///|
pub extend MethodSelfType with Debug::{to_repr}

///|
pub extend FuncSig with Debug::{to_repr}

///|
pub extend TypeDefinition with Debug::{to_repr}

///|
pub extend TypeSig with Debug::{to_repr}

///|
pub extend AliasSig with Debug::{to_repr}

///|
pub extend TraitMethodSig with Debug::{to_repr}

///|
pub extend TraitSig with Debug::{to_repr}

///|
pub extend ImplSig with Debug::{to_repr}

///|
pub extend ConstSig with Debug::{to_repr}

///|
pub extend ValueSig with Debug::{to_repr}

///|
pub extend PackageImport with Debug::{to_repr}

///|
pub extend Sig with Debug::{to_repr}

///|
pub extend Mbti with Debug::{to_repr}
1 change: 1 addition & 0 deletions mbti_parser/pkg.generated.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub suberror ParseError {
UnexpectedToken(@tokens.Token, (@basic.Position, @basic.Position), Array[@tokens.TokenKind])
UnexpectedEndOfInput(@basic.Position, Array[@tokens.TokenKind])
} derive(@debug.Debug)
pub fn ParseError::to_repr(Self) -> @debug.Repr

// Types and methods

Expand Down
2 changes: 2 additions & 0 deletions mbti_parser/trait_extensions.mbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
///|
pub extend ParseError with Debug::{to_repr}
Loading
Loading