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
2 changes: 1 addition & 1 deletion lexer/moon.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "moonbitlang/lexer"

version = "0.3.11"
version = "0.3.12"

repository = "https://github.com/moonbitlang/parser"

Expand Down
6 changes: 3 additions & 3 deletions moon.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name = "moonbitlang/parser"

version = "0.3.11"
version = "0.3.12"

import {
"moonbitlang/x@0.4.39",
"moonbitlang/lexer@0.3.11",
"moonbitlang/moon_config@0.3.10",
"moonbitlang/lexer@0.3.12",
"moonbitlang/moon_config@0.3.11",
"moonbit-community/miniio@0.1.0",
"moonbitlang/async@0.19.0",
"moonbit-community/prettyprinter@0.4.10",
Expand Down
4 changes: 2 additions & 2 deletions moon_config/moon.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name = "moonbitlang/moon_config"

version = "0.3.10"
version = "0.3.11"

import {
"moonbitlang/lexer@0.3.11",
"moonbitlang/lexer@0.3.12",
}

repository = "https://github.com/moonbitlang/parser"
Expand Down
215 changes: 0 additions & 215 deletions report.md

This file was deleted.

12 changes: 4 additions & 8 deletions untyped_cst/README.mbt.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,24 @@ Use `parse_structure(source, name?)` for a MoonBit source file and
`parse_expression(source, name?)` for a standalone expression. Both return a
`ParseResult`.

- `parse_structure` returns a root whose kind is `SourceFile`.
- `parse_expression` returns a root whose kind is `ExpressionFragment`.
- `parse_structure` returns a root whose kind is `Impls`.
- `parse_expression` returns a root whose kind is `Expression`.

Successful results can be lowered with `ParseResult::to_impls` and
`ParseResult::to_expr`, respectively. Calling a lowering method for the other
root kind returns a diagnostic.

## Source Text

CST nodes do not own the original source text. Keep the original `source` and
pass it to `CstNode::text(source)` when reconstructing text for a node. The
method returns a zero-copy `StringView` backed by that source; call
`to_owned()` explicitly if an owned `String` is required.
CST nodes do not own the original source text.

`CstNode.source_span` is a pair of UTF-16 code-unit offsets: an inclusive start
and an exclusive end. They can be used directly as `String`/`StringView`
slicing offsets. Keep using the same source string when calling `text(source)`.
slicing offsets.

Parse source text with one of the two entry points so every node span refers to
the original source string.


## Note

The `untyped_cst` package must remain behaviorally equivalent to
Expand Down
4 changes: 2 additions & 2 deletions untyped_cst/api.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn parse_source(
///|
/// Parses a MoonBit source file into a concrete syntax tree.
///
/// The returned root node has kind `SourceFile`. Its source spans use UTF-16
/// The returned root node has kind `Impls`. Its source spans use UTF-16
/// code-unit offsets suitable for slicing the original `source` string.
pub fn parse_structure(source : String, name? : String = "") -> ParseResult {
parse_source(source, name, parse_source_file)
Expand All @@ -39,7 +39,7 @@ pub fn parse_structure(source : String, name? : String = "") -> ParseResult {
///|
/// Parses a MoonBit expression into a concrete syntax tree.
///
/// The returned root node has kind `ExpressionFragment`. Its source spans use
/// The returned root node has kind `Expression`. Its source spans use
/// UTF-16 code-unit offsets suitable for slicing the original `source` string.
pub fn parse_expression(source : String, name? : String = "") -> ParseResult {
parse_source(source, name, parse_expr_fragment)
Expand Down
Loading
Loading