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
12 changes: 4 additions & 8 deletions attribute/pkg.generated.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,24 @@ pub fn payloads(Array[(@tokens.Token, @basic.Position, @basic.Position)], initia
pub suberror ParseError {
UnexpectedToken(@tokens.Token, (@basic.Position, @basic.Position), Array[@tokens.TokenKind])
UnexpectedEndOfInput(@basic.Position, Array[@tokens.TokenKind])
}
pub impl @debug.Debug for ParseError
} derive(@debug.Debug)

// Types and methods
pub(all) struct Attribute {
loc : @basic.Location
raw : String
parsed : Expr?
}
} derive(@debug.Debug)
pub fn Attribute::name(Self) -> String?
pub fn Attribute::new(loc~ : @basic.Location, (String, String?, String)) -> Self
pub impl ToJson for Attribute
pub impl @debug.Debug for Attribute

pub(all) enum Expr {
Ident(Id)
String(String)
Apply(Id, @list.List[Prop])
Bool(Bool)
}
pub impl @debug.Debug for Expr
} derive(@debug.Debug)

pub(all) struct Id {
qual : String?
Expand All @@ -47,8 +44,7 @@ pub impl @debug.Debug for Id
pub(all) enum Prop {
Labeled(String, Expr)
Expr(Expr)
}
pub impl @debug.Debug for Prop
} derive(@debug.Debug)

// Type aliases

Expand Down
11 changes: 2 additions & 9 deletions basic/pkg.generated.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,23 @@ pub(all) enum LocStyle {
pub(all) struct Location {
start : Position
end : Position
}
} derive(Compare, Eq, Hash, @debug.Debug)
pub fn Location::merge(Self, Self) -> Self
pub fn Location::trim_first_char(Self) -> Self
pub fn Location::trim_last_char(Self) -> Self
pub impl Compare for Location
pub impl Eq for Location
pub impl Hash for Location
pub impl Show for Location
pub impl ToJson for Location
pub impl @debug.Debug for Location

pub(all) struct Position {
fname : String
lnum : Int
bol : Int
cnum : Int
}
} derive(Hash, ToJson, @debug.Debug)
pub fn Position::column(Self) -> Int
pub impl Compare for Position
pub impl Eq for Position
pub impl Hash for Position
pub impl Show for Position
pub impl ToJson for Position
pub impl @debug.Debug for Position

pub(all) struct Report {
loc : Location
Expand Down
2 changes: 1 addition & 1 deletion lexer/lex.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub fn tokens_from_string(
}
lex_tokens(str, base=str, env~, preserve_comment=env.preserve_comment())
let docstrings = env.docstrings
if not(docstrings.is_empty()) {
if !docstrings.is_empty() {
let last_idx = docstrings.length() - 1
docstrings[last_idx] = docstrings[last_idx].rev()
}
Expand Down
4 changes: 2 additions & 2 deletions lexer/lex_env.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ fn LexEnv::add_token(
// Make sure add trailing newline if the comment is at end of file
let trailing_newlines = @cmp.minimum(2, count_newlines(i, 1))
let (_, start, end) = self.tokens[i]
let kind = if leading_newlines == 0 && not(at_file_start) {
let kind = if leading_newlines == 0 && !at_file_start {
CommentKind::InlineTrailing
} else {
Ownline(
leading_blank_line=leading_newlines == 2 && not(at_file_start),
leading_blank_line=leading_newlines == 2 && !at_file_start,
trailing_blank_line=trailing_newlines == 2,
)
}
Expand Down
12 changes: 6 additions & 6 deletions lexer/lexer.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ fn lex_tokens(
// Dot with number
("\.[0-9]+" as dot_int, rest) => {
let digits_str = dot_int.sub(start=1, end=dot_int.length()) // Remove the '.'
let idx = @strconv.parse_int(digits_str) catch {
let idx = @string.parse_int(digits_str) catch {
_ => {
let full_str = dot_int.to_string()
env.add_lexing_error(
Expand Down Expand Up @@ -1057,7 +1057,7 @@ fn lex_string(
string_repr_buf.write_char('"')
process_string(rest, start_pos)
} else {
if not(string_repr_buf.is_empty()) {
if !string_repr_buf.is_empty() {
add_literal(
string_repr_buf.to_string(),
start_pos,
Expand Down Expand Up @@ -1104,7 +1104,7 @@ fn lex_string(
rest
) =>
if allow_interp {
if not(string_repr_buf.is_empty()) {
if !string_repr_buf.is_empty() {
add_literal(
string_repr_buf.to_string(),
start_pos,
Expand Down Expand Up @@ -1144,7 +1144,7 @@ fn lex_string(
end=env.calc_offset(base~, input),
UnterminatedString,
)
if not(string_repr_buf.is_empty()) {
if !string_repr_buf.is_empty() {
add_literal(
string_repr_buf.to_string(),
start_pos,
Expand All @@ -1157,10 +1157,10 @@ fn lex_string(
// CRLF
("[\r\n]", rest) => {
let end_pos = env.calc_offset(base~, rest)
if not(end_with_newline) {
if !end_with_newline {
env.add_lexing_error(start=start_pos, end=end_pos, UnterminatedString)
}
if not(string_repr_buf.is_empty()) {
if !string_repr_buf.is_empty() {
add_literal(string_repr_buf.to_string(), start_pos, end_pos)
}
// Need to back off to handle NEWLINE token
Expand Down
2 changes: 1 addition & 1 deletion lexer/moon.pkg
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
"moonbitlang/parser/tokens",
"moonbitlang/parser/basic",
"moonbitlang/core/list",
"moonbitlang/core/strconv",
"moonbitlang/core/string",
"moonbitlang/core/cmp",
"moonbitlang/core/ref",
"moonbitlang/core/hashset",
Expand Down
3 changes: 1 addition & 2 deletions mbti_ast/pkg.generated.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ pub(all) struct MethodSelfType {
pub(all) struct Name {
name : String
loc : @basic.Location
}
pub impl ToJson for Name
} derive(ToJson)

pub(all) struct PackageImport {
name : String
Expand Down
3 changes: 1 addition & 2 deletions mbti_parser/pkg.generated.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ pub fn mbti(Array[(@tokens.Token, @basic.Position, @basic.Position)], initial_po
pub suberror ParseError {
UnexpectedToken(@tokens.Token, (@basic.Position, @basic.Position), Array[@tokens.TokenKind])
UnexpectedEndOfInput(@basic.Position, Array[@tokens.TokenKind])
}
pub impl @debug.Debug for ParseError
} derive(@debug.Debug)

// Types and methods

Expand Down
4 changes: 1 addition & 3 deletions pkg_parser/pkg.generated.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,14 @@ pub(all) enum Ast {
Float(float~ : String, loc~ : @basic.Location)
Arr(content~ : Array[Ast], loc~ : @basic.Location)
Obj(map~ : Map[String, Ast], loc~ : @basic.Location)
}
} derive(Eq, @debug.Debug)
pub fn Ast::as_array(Self) -> Array[Self]?
pub fn Ast::as_bool(Self) -> Bool?
pub fn Ast::as_number(Self) -> String?
pub fn Ast::as_object(Self) -> Map[String, Self]?
pub fn Ast::as_string(Self) -> String?
pub fn Ast::loc(Self) -> @basic.Location
pub impl Eq for Ast
pub impl ToJson for Ast
pub impl @debug.Debug for Ast

// Type aliases

Expand Down
2 changes: 1 addition & 1 deletion test/mbti_parser_test/helper_test.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn @test.Test::run(t : Self, filename : String) -> Unit raise {
)
let mbti = @mbti_parser.mbti(
lex_result.tokens.filter(fn(triple) {
not(triple.0 is (NEWLINE | COMMENT(_)))
!(triple.0 is (NEWLINE | COMMENT(_)))
}),
initial_pos=@basic.Position::{ fname: filename, lnum: 1, bol: 0, cnum: 0 },
)
Expand Down
26 changes: 6 additions & 20 deletions tokens/pkg.generated.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,24 @@ pub(all) struct Comment {
content : String
kind : CommentKind
mut consumed_by_docstring : Bool
}
pub impl Eq for Comment
} derive(Eq, @debug.Debug)
pub impl ToJson for Comment
pub impl @debug.Debug for Comment

pub(all) enum CommentKind {
InlineTrailing
Ownline(leading_blank_line~ : Bool, trailing_blank_line~ : Bool)
}
pub impl Eq for CommentKind
} derive(Eq, @debug.Debug)
pub impl ToJson for CommentKind
pub impl @debug.Debug for CommentKind

pub(all) enum InterpElem {
InterpLit(repr~ : String, loc~ : @basic.Location)
InterpSource(InterpSource)
}
pub impl Eq for InterpElem
pub impl @debug.Debug for InterpElem
} derive(Eq, @debug.Debug)

pub(all) struct InterpSource {
source : String
loc : @basic.Location
}
pub impl Eq for InterpSource
pub impl ToJson for InterpSource
pub impl @debug.Debug for InterpSource
} derive(Eq, ToJson, @debug.Debug)

pub(all) enum Token {
CHAR(String)
Expand Down Expand Up @@ -159,11 +150,10 @@ pub(all) enum Token {
LEXMATCH
LEXMATCH_QUESTION
PACKAGE
}
} derive(@debug.Debug)
pub fn Token::kind(Self) -> TokenKind
pub fn Token::to_expect_string(Self) -> String
pub impl ToJson for Token
pub impl @debug.Debug for Token

pub(all) enum TokenKind {
TK_CHAR
Expand Down Expand Up @@ -281,13 +271,9 @@ pub(all) enum TokenKind {
TK_LEXMATCH
TK_LEXMATCH_QUESTION
TK_PACKAGE
}
} derive(Compare, Eq, Hash, @debug.Debug)
pub fn TokenKind::to_expect_string(Self) -> String
pub impl Compare for TokenKind
pub impl Eq for TokenKind
pub impl Hash for TokenKind
pub impl Show for TokenKind
pub impl @debug.Debug for TokenKind

// Type aliases
pub type ByteLiteral = String
Expand Down
3 changes: 1 addition & 2 deletions yacc_parser/pkg.generated.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ pub fn structure(Array[(@tokens.Token, @basic.Position, @basic.Position)], initi
pub suberror ParseError {
UnexpectedToken(@tokens.Token, (@basic.Position, @basic.Position), Array[@tokens.TokenKind])
UnexpectedEndOfInput(@basic.Position, Array[@tokens.TokenKind])
}
pub impl @debug.Debug for ParseError
} derive(@debug.Debug)

// Types and methods

Expand Down
Loading