An open API service indexing awesome lists of open source software.

https://github.com/oboard/mbx-compiler


https://github.com/oboard/mbx-compiler

compiler moonbit

Last synced: 5 months ago
JSON representation

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
}
```