Skip to content
Merged
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: 4 additions & 4 deletions attribute/attribute_test.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ test "attribute" {
inspect(
attr,
content=(
#|{loc: -0:1-0:1, raw: "#qual.name(a,b,c)", parsed: Some(Apply(qual.name, @list.of([Expr(Ident(a)), Expr(Ident(b)), Expr(Ident(c))])))}
#|{loc: -0:1-0:1, raw: "#qual.name(a,b,c)", parsed: Some(Apply(qual.name, @list.from_array([Expr(Ident(a)), Expr(Ident(b)), Expr(Ident(c))])))}
),
)
let attr = Attribute::new(
Expand All @@ -20,7 +20,7 @@ test "attribute" {
inspect(
attr,
content=(
#|{loc: -0:1-0:1, raw: "#qual.name(label1=abc, label2=cde)", parsed: Some(Apply(qual.name, @list.of([Labeled("label1", Ident(abc)), Labeled("label2", Ident(cde))])))}
#|{loc: -0:1-0:1, raw: "#qual.name(label1=abc, label2=cde)", parsed: Some(Apply(qual.name, @list.from_array([Labeled("label1", Ident(abc)), Labeled("label2", Ident(cde))])))}
),
)
let attr = Attribute::new(
Expand All @@ -30,7 +30,7 @@ test "attribute" {
inspect(
attr,
content=(
#|{loc: -0:1-0:1, raw: "#qual.name(f(false), g(true))", parsed: Some(Apply(qual.name, @list.of([Expr(Apply(f, @list.of([Expr(Bool(false))]))), Expr(Apply(g, @list.of([Expr(Bool(true))])))])))}
#|{loc: -0:1-0:1, raw: "#qual.name(f(false), g(true))", parsed: Some(Apply(qual.name, @list.from_array([Expr(Apply(f, @list.from_array([Expr(Bool(false))]))), Expr(Apply(g, @list.from_array([Expr(Bool(true))])))])))}
),
)
let attr = Attribute::new(
Expand All @@ -40,7 +40,7 @@ test "attribute" {
inspect(
attr,
content=(
#|{loc: -0:1-0:1, raw: "#qual.name(\"abcdef\", g(true))", parsed: Some(Apply(qual.name, @list.of([Expr(String("abcdef")), Expr(Apply(g, @list.of([Expr(Bool(true))])))])))}
#|{loc: -0:1-0:1, raw: "#qual.name(\"abcdef\", g(true))", parsed: Some(Apply(qual.name, @list.from_array([Expr(String("abcdef")), Expr(Apply(g, @list.from_array([Expr(Bool(true))])))])))}
),
)
let attr = Attribute::new(loc=dummy_loc, ("qual", Some("name"), ""))
Expand Down
22 changes: 11 additions & 11 deletions attribute/imports.mbt
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
///|
typealias @list.List
using @list {type List}

///|
typealias @basic.(Location, Position)
using @basic {type Location, type Position}

///|
typealias @tokens.(Token, TokenKind)
using @tokens {type Token, type TokenKind}

///|
typealias @tokens.(
StringLiteral,
InterpLiteral,
ByteLiteral,
BytesLiteral,
CharLiteral,
Comment
)
using @tokens {
type StringLiteral,
type InterpLiteral,
type ByteLiteral,
type BytesLiteral,
type CharLiteral,
type Comment,
}
8 changes: 4 additions & 4 deletions attribute/parser.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ priv suberror YYObj_StringLiteral StringLiteral
priv suberror YYObj__String__String___String_ (String, String?, String)

///|
typealias (YYSymbol) -> YYDecision as YYState
type YYState = (YYSymbol) -> YYDecision

///|
typealias (Position, ArrayView[(YYObj, Position, Position)]) -> YYObj as YYAction
type YYAction = (Position, ArrayView[(YYObj, Position, Position)]) -> YYObj

///|
priv enum YYDecision {
Expand Down Expand Up @@ -423,7 +423,7 @@ fn yy_action_13(
}

// file:///./parser.mbty
// 161| property { @list.of([$1]) }
// 161| property { @list.from_array([$1]) }

///|
fn yy_action_14(
Expand All @@ -434,7 +434,7 @@ fn yy_action_14(
YYObj_List_Prop_(
{
()
@list.of([_dollar1])
@list.from_array([_dollar1])
},
)
}
Expand Down
10 changes: 5 additions & 5 deletions attribute/parser.mbt.map.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,20 @@
},
{
"source": "parser.mbty",
"original_offset": 3739,
"original_offset": 3747,
"generated_offset": 6283,
"length": 11
},
{
"source": "parser.mbty",
"original_offset": 3678,
"generated_offset": 6528,
"length": 11
"generated_offset": 6536,
"length": 19
},
{
"source": "parser.mbty",
"original_offset": 3691,
"generated_offset": 6547,
"original_offset": 3699,
"generated_offset": 6563,
"length": 3
}
]
Expand Down
2 changes: 1 addition & 1 deletion attribute/parser.mbty
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,6 @@ properties -> List[Prop]:
| "(" non_empty_properties ")" { $2 }

non_empty_properties -> List[Prop]:
| property { @list.of([$1]) }
| property { @list.from_array([$1]) }
| x=property "," xs=non_empty_properties{ xs.add(x) }

11 changes: 0 additions & 11 deletions attribute/pkg.generated.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ pub suberror ParseError {
UnexpectedToken(@tokens.Token, (@basic.Position, @basic.Position), Array[@tokens.TokenKind])
UnexpectedEndOfInput(@basic.Position, Array[@tokens.TokenKind])
}
fn ParseError::output(Self, &Logger) -> Unit // from trait `Show`
fn ParseError::to_string(Self) -> String // from trait `Show`
impl Show for ParseError

// Types and methods
Expand All @@ -27,9 +25,6 @@ pub(all) struct Attribute {
}
fn Attribute::name(Self) -> String?
fn Attribute::new(loc~ : @basic.Location, (String, String?, String)) -> Self
fn Attribute::output(Self, &Logger) -> Unit // from trait `Show`
fn Attribute::to_json(Self) -> Json // from trait `ToJson`
fn Attribute::to_string(Self) -> String // from trait `Show`
impl Show for Attribute
impl ToJson for Attribute

Expand All @@ -39,24 +34,18 @@ pub(all) enum Expr {
Apply(Id, @list.List[Prop])
Bool(Bool)
}
fn Expr::output(Self, &Logger) -> Unit // from trait `Show`
fn Expr::to_string(Self) -> String // from trait `Show`
impl Show for Expr

pub(all) struct Id {
qual : String?
name : String
}
fn Id::output(Self, &Logger) -> Unit // from trait `Show`
fn Id::to_string(Self) -> String // from trait `Show`
impl Show for Id

pub(all) enum Prop {
Labeled(String, Expr)
Expr(Expr)
}
fn Prop::output(Self, &Logger) -> Unit // from trait `Show`
fn Prop::to_string(Self) -> String // from trait `Show`
impl Show for Prop

// Type aliases
Expand Down
2 changes: 1 addition & 1 deletion basic/loc.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ test "compre position" {
}

///|
pub fn column(self : Position) -> Int {
pub fn Position::column(self : Position) -> Int {
self.cnum - self.bol + 1
}

Expand Down
21 changes: 0 additions & 21 deletions basic/pkg.generated.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,7 @@ pub(all) struct Location {
start : Position
end : Position
}
fn Location::compare(Self, Self) -> Int // from trait `Compare`
fn Location::equal(Self, Self) -> Bool // from trait `Eq`
fn Location::hash(Self) -> Int // from trait `Hash`
fn Location::hash_combine(Self, Hasher) -> Unit // from trait `Hash`
fn Location::merge(Self, Self) -> Self
#deprecated
fn Location::op_equal(Self, Self) -> Bool // from trait `Eq`
fn Location::output(Self, &Logger) -> Unit // from trait `Show`
fn Location::to_json(Self) -> Json // from trait `ToJson`
fn Location::to_string(Self) -> String // from trait `Show`
fn Location::trim_first_char(Self) -> Self
fn Location::trim_last_char(Self) -> Self
impl Compare for Location
Expand All @@ -46,15 +37,6 @@ pub(all) struct Position {
cnum : Int
}
fn Position::column(Self) -> Int
fn Position::compare(Self, Self) -> Int // from trait `Compare`
fn Position::equal(Self, Self) -> Bool // from trait `Eq`
fn Position::hash(Self) -> Int // from trait `Hash`
fn Position::hash_combine(Self, Hasher) -> Unit // from trait `Hash`
#deprecated
fn Position::op_equal(Self, Self) -> Bool // from trait `Eq`
fn Position::output(Self, &Logger) -> Unit // from trait `Show`
fn Position::to_json(Self) -> Json // from trait `ToJson`
fn Position::to_string(Self) -> String // from trait `Show`
impl Compare for Position
impl Eq for Position
impl Hash for Position
Expand All @@ -65,9 +47,6 @@ pub(all) struct Report {
loc : Location
msg : String
}
fn Report::output(Self, &Logger) -> Unit // from trait `Show`
fn Report::to_json(Self) -> Json // from trait `ToJson`
fn Report::to_string(Self) -> String // from trait `Show`
impl Show for Report
impl ToJson for Report

Expand Down
14 changes: 7 additions & 7 deletions handrolled_parser/imports.mbt
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
///|
/// Import types from ast_types package
typealias @basic.(Location, Position, Report)
using @basic {type Location, type Position, type Report}

///|
/// Import AST types
typealias @syntax.(Impls, DocString)
using @syntax {type Impls, type DocString}

///|
typealias @tokens.(Token, TokenKind)
using @tokens {type Token, type TokenKind}

///|
typealias (Token, Position, Position) as Triple
type Triple = (Token, Position, Position)

///|
typealias @util.Statement
using @util {type Statement}

///|
typealias @list.List
using @list {type List}

///|
typealias @attribute.Attribute
using @attribute {type Attribute}
32 changes: 20 additions & 12 deletions handrolled_parser/parser.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,11 @@ fn State::parse_var(self : Self) -> @syntax.Var {
///|
fn State::parse_tvar_binder(self : Self) -> @syntax.TypeVarBinder {
if self.mode is Panic(loc~, ..) {
return { name: "?tvar_name", name_loc: loc, constraints: @list.of([]) }
return {
name: "?tvar_name",
name_loc: loc,
constraints: @list.from_array([]),
}
}
let spos = self.peek_spos()
let name = self.parse_luident()
Expand Down Expand Up @@ -754,7 +758,7 @@ fn State::parse_typealias(
let loc = self.loc_start_with(spos)
TopBatchTypeAlias(
pkg=None,
targets=@list.of([target]),
targets=@list.from_array([target]),
vis~,
attrs~,
loc~,
Expand Down Expand Up @@ -1239,11 +1243,11 @@ fn State::parse_top(self : Self) -> @syntax.Impl {
(xs, true)
}
DOT_LIDENT(_) if need_dot => {
let xs = @list.of([parse_target(self, need_dot)])
let xs = @list.from_array([parse_target(self, need_dot)])
(xs, false)
}
LIDENT(_) if !need_dot => {
let xs = @list.of([parse_target(self, need_dot)])
let xs = @list.from_array([parse_target(self, need_dot)])
(xs, false)
}
other => {
Expand Down Expand Up @@ -1339,7 +1343,7 @@ fn State::parse_top(self : Self) -> @syntax.Impl {
let target_loc = self.peek_location()
self.skip()
let target = parse_target(self, target_name, target_loc)
(false, @list.of([target]))
(false, @list.from_array([target]))
}
other => {
let other_loc = self.peek_location()
Expand Down Expand Up @@ -1379,7 +1383,7 @@ fn State::parse_top(self : Self) -> @syntax.Impl {
}
TopBatchTraitAlias(
pkg~,
targets=@list.of([{ binder, target: Some(target) }]),
targets=@list.from_array([{ binder, target: Some(target) }]),
vis~,
loc~,
attrs~,
Expand All @@ -1394,7 +1398,7 @@ fn State::parse_top(self : Self) -> @syntax.Impl {
let loc = self.loc_start_with(spos)
TopBatchTraitAlias(
pkg=None,
targets=@list.of([target]),
targets=@list.from_array([target]),
vis~,
is_list=false,
loc~,
Expand Down Expand Up @@ -3181,7 +3185,11 @@ fn State::parse_expr(self : Self) -> @syntax.Expr {
self.expect_token(TK_FAT_ARROW)
let body = self.parse_expr_stmt_no_break_continue_return()
let loc = self.loc_start_with(spos)
let func = @syntax.make_arrow_fn(@list.of([(p, None)]), body, loc~)
let func = @syntax.make_arrow_fn(
@list.from_array([(p, None)]),
body,
loc~,
)
Function(loc~, func~)
}
_ => self.parse_simple_try_expr(parsed=None)
Expand Down Expand Up @@ -3319,7 +3327,7 @@ fn State::parse_infix_expr(

let first_spos = self.peek_spos_with_parsed(parsed~)
let first_expr = self.parse_postfix_expr(parsed~)
let (_, expr) = go(@list.of([(first_spos, first_expr)]), @list.new())
let (_, expr) = go(@list.from_array([(first_spos, first_expr)]), @list.new())
expr
}

Expand Down Expand Up @@ -4127,7 +4135,7 @@ fn State::parse_semi_trailing_record(self : Self) -> @syntax.Expr {
self.expect_token(TK_SEMI)
self.expect_token(TK_RBRACE)
let loc = self.loc_start_with(spos)
Record(type_name=None, fields=@list.of([field]), trailing=Semi, loc~)
Record(type_name=None, fields=@list.from_array([field]), trailing=Semi, loc~)
}

///|
Expand Down Expand Up @@ -4358,7 +4366,7 @@ fn State::parse_letand_func(self : Self) -> @syntax.Func {
self.expect_token(TK_FAT_ARROW)
let body = self.parse_expr_stmt_no_break_continue_return()
let loc = self.loc_start_with(spos)
@syntax.make_arrow_fn(@list.of([(param, None)]), body, loc~)
@syntax.make_arrow_fn(@list.from_array([(param, None)]), body, loc~)
}
_ => {
let is_async = if self.peek_token() is ASYNC {
Expand Down Expand Up @@ -4478,7 +4486,7 @@ fn State::handle_unexpected_expr_or_statement(
| StmtDefer(loc~, ..)
| StmtGuard(loc~, ..) => loc
}
Statement::compact_rev(@list.of([stmt]), loc~)
Statement::compact_rev(@list.from_array([stmt]), loc~)
}

let (actual, expr) = match token {
Expand Down
11 changes: 8 additions & 3 deletions lexer/imports.mbt
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
///|
typealias @tokens.Token
using @tokens {type Token}

///|
typealias @basic.(Position, Location)
using @basic {type Position, type Location}

///|
typealias @tokens.(Comment, CommentKind, InterpElem, InterpSource)
using @tokens {
type Comment,
type CommentKind,
type InterpElem,
type InterpSource,
}
Loading