Skip to content

Commit 705a7d8

Browse files
committed
align with new moonbit release
1 parent 396a627 commit 705a7d8

File tree

9 files changed

+20
-32
lines changed

9 files changed

+20
-32
lines changed

moon.mod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "moonbitlang/yacc",
3-
"version": "0.3.32",
3+
"version": "0.3.33",
44
"deps": {
55
"moonbitlang/x": "0.4.23",
66
"Yoorkin/ArgParser": "0.1.9"

src/lib/driver/driver.mbt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
// You should have received a copy of the GNU General Public License
1313
// along with this program; if not, see <https://www.gnu.org/licenses/>.
1414

15+
///|
16+
fnalias @util.(println_to_stderr, exit, path_basename)
17+
1518
///|
1619
pub(all) enum Mode {
1720
Default
@@ -81,7 +84,7 @@ pub fn compile(
8184
@elab.elaborate_with_stdlib_rules!(
8285
spec,
8386
parser_spec_str,
84-
@_driver_util.path_basename(filename),
87+
path_basename(filename),
8588
json_cst=match mode {
8689
JsonCst => Yes
8790
Default | OnlyTokens => No
@@ -282,7 +285,7 @@ pub fn compile(
282285
meta,
283286
output,
284287
source_map_builder~,
285-
grammar_filename=@_driver_util.path_basename(filename),
288+
grammar_filename=path_basename(filename),
286289
mode=match mode {
287290
OnlyTokens => panic()
288291
Default => Default

src/lib/driver/moon.pkg.json

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,10 @@
44
"moonbitlang/yacc/lib/parser",
55
"moonbitlang/yacc/lib/codegen",
66
"moonbitlang/yacc/lib/lr1",
7-
{
8-
"path": "moonbitlang/yacc/lib/driver/util",
9-
"alias": "_driver_util",
10-
"value": [
11-
"println_to_stderr",
12-
"exit"
13-
]
14-
},
157
"moonbitlang/yacc/lib/util/logger_with_cursor",
168
"moonbitlang/yacc/lib/elab",
179
"moonbitlang/yacc/lib/util/array_multimap",
18-
"moonbitlang/yacc/lib/desugar"
10+
"moonbitlang/yacc/lib/desugar",
11+
"moonbitlang/yacc/lib/driver/util"
1912
]
2013
}

src/lib/driver/util/util.mbt

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
///|
22
pub fn path_basename(path : String) -> String {
3-
let lastSlashIndex = path.last_index_of("/")
4-
if lastSlashIndex == -1 {
3+
if path.rev_find("/") is Some(lastSlashIndex) {
4+
path.substring(start=lastSlashIndex + 1)
55
// Fallback to windows path separator
6-
let lastBackslashIndex = path.last_index_of("\\")
7-
if lastBackslashIndex == -1 {
8-
return path
9-
} else {
10-
return path.substring(start=lastBackslashIndex + 1)
11-
}
6+
} else if path.rev_find("\\") is Some(lastBackslashIndex) {
7+
return path.substring(start=lastBackslashIndex + 1)
128
} else {
13-
path.substring(start=lastSlashIndex + 1)
9+
return path
1410
}
1511
}

src/lib/lr1/epsilon_lookahead_set.mbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ fn EpsilonLookaheadSet::union[T : AbstractLookaheadSet](
3333

3434
///|
3535
/// epsilon free first
36-
fn EpsilonLookaheadSet::op_add[T : AbstractLookaheadSet](
36+
impl[T : AbstractLookaheadSet] Add for EpsilonLookaheadSet[T] with op_add(
3737
set1 : EpsilonLookaheadSet[T],
3838
set2 : EpsilonLookaheadSet[T]
3939
) -> EpsilonLookaheadSet[T] {

src/lib/parser/lexer.mbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3656,7 +3656,7 @@ fn code_rbrace(
36563656
let (_start_pos_of_t2, _end_pos_of_t2) = __mbtlex_captures[2]
36573657
let t2 : String = lexbuf.substring(_start_pos_of_t2, _end_pos_of_t2)
36583658
sb.write_string(t)
3659-
let arg : @ast.ClauseItemIdent = if t2.starts_with("$") {
3659+
let arg : @ast.ClauseItemIdent = if t2.has_prefix("$") {
36603660
let index = try {
36613661
@strconv.parse_int!(t2.substring(start=1), base=10)
36623662
} catch {

src/lib/parser/lexer.mbtx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ rule code_rbrace(sb : StringBuilder, subst: Array[@ast.SubstItem], base : Int) -
146146
}
147147
("$" (("startpos" | "endpos" | "loc") as t1) "(" [' ' '\t']* (("$" ['0'-'9']+ | ['A'-'Z' 'a'-'z' '_'] ['A'-'Z' 'a'-'z' '0'-'9' '_']*) as t2) [' ' '\t']* ")") as t => {
148148
sb.write_string(t)
149-
let arg : @ast.ClauseItemIdent = if t2.starts_with("$") {
149+
let arg : @ast.ClauseItemIdent = if t2.has_prefix("$") {
150150
let index = try @strconv.parse_int!(t2.substring(start=1), base=10) catch { err => abort(Show::to_string(err)) }
151151
Dollar(index)
152152
} else {

src/main/main.mbt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
// You should have received a copy of the GNU General Public License
1313
// along with this program; if not, see <https://www.gnu.org/licenses/>.
1414

15+
fnalias @util.(println_to_stderr, exit)
16+
1517
///|
1618
fn main {
1719
let usage =

src/main/moon.pkg.json

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,9 @@
55
"moonbitlang/x/sys",
66
"Yoorkin/ArgParser",
77
"moonbitlang/yacc/lib/driver",
8-
{
9-
"path": "moonbitlang/yacc/lib/driver/util",
10-
"value": [
11-
"println_to_stderr",
12-
"exit"
13-
]
14-
},
158
"moonbitlang/yacc/lib/codegen",
16-
"moonbitlang/yacc/lib/codegen/gen_mbt"
9+
"moonbitlang/yacc/lib/codegen/gen_mbt",
10+
"moonbitlang/yacc/lib/driver/util"
1711
],
1812
"link": {
1913
"native": {

0 commit comments

Comments
 (0)