Skip to content

Commit cc7a990

Browse files
authored
docs: update for MoonBit v0.10.8 (#1302)
1 parent 9d0b756 commit cc7a990

31 files changed

Lines changed: 1356 additions & 982 deletions

File tree

‎next/check_error_docs.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@
3838
'4184',
3939
'4185',
4040
'4186',
41+
# These diagnostics are no longer independently reachable from source.
42+
# Their pages document that invalid template-writing operands and
43+
# lexmatch/lexscan guards are now rejected earlier by the parser with E3002.
44+
'4215',
45+
'4217',
4146
# These internal diagnostics are not meant to appear as independent
4247
# user-facing errors.
4348
'1000',

‎next/conf.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
project = 'MoonBit'
1010
author = 'International Digital Economy Academy'
1111
copyright = '%Y, {author}'.format(author=author)
12-
release = 'v0.10.7'
12+
release = 'v0.10.8'
1313

1414
# I18N based on Readthedocs Environment
1515
# https://docs.readthedocs.io/en/stable/reference/environment-variables.html

‎next/language/error_codes/E0027.md‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ For example, one deprecated usage is declaring a polymorphic function as
99
`fn f[T]`. Instead, write the type parameters before the function name, as in
1010
`fn[T] f`.
1111

12-
The compiler also reports this warning when `lexscan` is used with a `String`
13-
or `StringView` target. That compatibility form is temporarily accepted, but
14-
new code should use `lexmatch` for in-memory lexical matching.
15-
1612
## Erroneous example
1713

1814
```{literalinclude} /sources/error_codes/0027_error/top.mbt

‎next/language/error_codes/E4215.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
Compiler diagnostic name: `expect_template_string`.
44

5-
Template writing expects a string template.
5+
This diagnostic described a non-template right-hand side of the `<+` operator
6+
and is not emitted by the current compiler. The parser now rejects this syntax
7+
with [E3002](E3002.md).
68

79
The `<+` template-writing operator writes a string template to the value on its
810
left. The right-hand side must be a string literal, an interpolated string, or a

‎next/language/error_codes/E4216.md‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
Compiler diagnostic name: `lexscan_catchall_binder_not_supported`.
44

5-
A streaming `lexscan` catch-all case uses a binder pattern.
5+
A `lexscan` catch-all case uses a binder pattern.
66

7-
Streaming cases consume input only when a regex matches. The final catch-all
8-
also handles end of input, so it does not bind a matched substring. Use `_` for
9-
that case and bind text with `as` on the regex cases that need it.
7+
`lexscan` consumes input only when a regex matches. The final catch-all also
8+
handles end of input, so it does not bind a matched substring. Use `_` for that
9+
case and bind text with `as` on the regex cases that need it. This also applies
10+
when the target is an in-memory `@lexbuf.StringScanner`.
1011

1112
## Erroneous example
1213

‎next/language/error_codes/E4217.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
Compiler diagnostic name: `lexscan_guard_not_supported`.
44

5-
`lexmatch` and `lexscan` cases do not support guard conditions.
5+
This diagnostic described a guard on a `lexmatch` or `lexscan` case and is not
6+
emitted by the current compiler. The parser now rejects this syntax with
7+
[E3002](E3002.md).
68

79
The scanner selects a case from its regex patterns before it evaluates the case
810
body. A guard would make that selection depend on an arbitrary expression.

‎next/language/error_codes/E4218.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ Compiler diagnostic name: `lexscan_pattern_not_anchored`.
44

55
A lexical regex pattern is not anchored where anchoring is required.
66

7-
Patterns used by streaming `lexscan`, or by either expression with the
8-
`longest` strategy, must start at the current input position. Anchor each such
9-
regex with `^`.
7+
Patterns used by `lexscan`, including scans of an in-memory
8+
`@lexbuf.StringScanner`, or by `lexmatch` with the `longest` strategy, must
9+
start at the current input position. Anchor each such regex with `^`.
1010

1111
## Erroneous example
1212

‎next/language/error_codes/E4220.md‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ A lexical case uses a binding that is not available in its matching mode.
66

77
For `String` and `StringView` inputs, first-match `lexmatch` supports both
88
`before=` and `after=`. Longest-match mode starts at the beginning of the input,
9-
so it supports `after=` but not `before=`. Streaming `lexscan` consumes its
10-
input buffer and does not expose unmatched prefixes or suffixes through these
11-
bindings.
9+
so it supports `after=` but not `before=`. `lexscan` does not support either
10+
binding: streaming targets consume their input buffers, while an in-memory
11+
`@lexbuf.StringScanner` stores the next scan position in its `cursor` field.
1212

1313
## Erroneous example
1414

@@ -18,8 +18,9 @@ bindings.
1818

1919
## Suggestion
2020

21-
Remove `before=`, anchor the regex at `^`, and use `after=` when the unmatched
22-
suffix is needed.
21+
For `lexscan`, remove `before=` or `after=` and anchor the regex at `^`. For
22+
`lexmatch`, remove `before=`, anchor the regex at `^`, and use `after=` when the
23+
unmatched suffix is needed.
2324

2425
```{literalinclude} /sources/error_codes/4220_fixed/top.mbt
2526
:language: moonbit

‎next/language/error_codes/E4222.md‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ Compiler diagnostic name: `invalid_lexscan_target`.
44

55
Invalid lexical matching target.
66

7-
`lexmatch` accepts an in-memory `String` or `StringView`. `lexscan` is intended
8-
for `@lexbuf.Lexbuf` or `@lexbuf.AsyncLexbuf`. It temporarily also accepts
9-
`String` and `StringView` for compatibility, but emits a deprecation warning;
10-
use `lexmatch` for those inputs. Other values, such as numbers or user-defined
11-
lexbuf-like types, cannot be matched by these expressions.
7+
`lexmatch` accepts an in-memory `String` or `StringView`. `lexscan` accepts an
8+
in-memory `@lexbuf.StringScanner`, a synchronous `@lexbuf.Lexbuf`, or an
9+
asynchronous `@lexbuf.AsyncLexbuf`. A `String` or `StringView` value is not a
10+
valid `lexscan` target; use `lexmatch` for one in-memory match, or construct a
11+
`StringScanner` to maintain a cursor between scans. Other values, such as
12+
numbers or user-defined lexbuf-like types, cannot be matched by these
13+
expressions.
1214

1315
## Erroneous example
1416

@@ -18,8 +20,8 @@ lexbuf-like types, cannot be matched by these expressions.
1820

1921
## Suggestion
2022

21-
Use `lexmatch` with a string-like value, or create a lexing buffer for
22-
`lexscan`.
23+
Use `lexmatch` with a string-like value, or create a `StringScanner`, `Lexbuf`,
24+
or `AsyncLexbuf` for `lexscan`.
2325

2426
```{literalinclude} /sources/error_codes/4222_fixed/top.mbt
2527
:language: moonbit

‎next/language/error_codes/E4224.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ define the result when no regex case matches.
1919
## Suggestion
2020

2121
Make the regex cases exhaustive, or add a final catch-all case. A `lexmatch`
22-
catch-all may bind the unmatched input; a streaming `lexscan` catch-all must be
23-
written as `_`. If a catch-all exists but is not last, see [E4171](E4171.md).
22+
catch-all may bind the unmatched input; a `lexscan` catch-all must be written
23+
as `_`, including when its target is a `StringScanner`. If a catch-all exists
24+
but is not last, see [E4171](E4171.md).
2425

2526
```{literalinclude} /sources/error_codes/4224_fixed/top.mbt
2627
:language: moonbit

0 commit comments

Comments
 (0)