https://github.com/oboard/mbx-compiler
https://github.com/oboard/mbx-compiler
compiler moonbit
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/oboard/mbx-compiler
- Owner: oboard
- License: apache-2.0
- Created: 2025-03-28T18:47:57.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-27T08:37:59.000Z (about 1 year ago)
- Last Synced: 2025-04-27T09:28:35.127Z (about 1 year ago)
- Topics: compiler, moonbit
- Language: TypeScript
- Homepage:
- Size: 37.1 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# oboard/mbx-compiler
## Clone
```bash
git clone --recursive https://github.com/oboard/mbx-compiler
```
## Example
### Source File
```moonbit
///|
enum AnotherMessage {}
///|
pub fn another_app() -> @html.Html[AnotherMessage] {
let count = 5
let the_section =
let compare_result = count < 0 || count > 42
let part =
Hello { if compare_result { "Moon" } else { "Bit" } }
language{" "}
{ compare_result.to_string() }
Here are some words...
let _ = false
part
}
```
### Run
```bash
ts-node main.ts
```
### Result
```moonbit
///|
enum AnotherMessage {}
///|
pub fn another_app() -> @html.Html[AnotherMessage] {
let count = 5
let the_section = @html.node(
"section",
[
@html.attribute("x", "{literal\"}"),
@html.attribute("y", count.to_string()),
],
[],
)
let compare_result = count < 0 || count > 42
let part = @html.node("container", [], [
@html.node("article", [@html.attribute("data", count.to_string())], [
@html.text("Hello"),
@html.text(if compare_result { "Moon" } else { "Bit" }),
@html.text("language"),
@html.text(" "),
@html.node("span", [], []),
]),
@html.text(compare_result.to_string()),
@html.node("article", [], []),
@html.text("Here are some words..."),
])
let _ = false
part
}
```