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 AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ You can browse and install extra skills here:
blackbox test files (ending in `_test.mbt`) and whitebox test files (ending in
`_wbtest.mbt`).

- In the toplevel directory, there is a `moon.mod.json` file listing module
- In the toplevel directory, there is a `moon.mod` file listing module
metadata.

## Coding convention
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING-ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ puruslang/purus
├── bin/ # CLI エントリポイント
├── scripts/ # ビルド・同期スクリプト
├── examples/ # サンプル .purus ファイル
├── moon.mod.json # MoonBit モジュール定義
├── moon.mod # MoonBit モジュール定義
└── package.json
```

Expand All @@ -42,7 +42,7 @@ node scripts/build.js
| `moon test` | 全テストの実行 |
| `moon check` | 型チェック |
| `npm run build` | フルビルド(コンパイル + コピー)|
| `npm run sync` | バージョンを moon.mod.json に同期 |
| `npm run sync` | バージョンを moon.mod に同期 |

## プルリクエストの提出

Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ puruslang/purus
├── bin/ # CLI entry point
├── scripts/ # Build & sync scripts
├── examples/ # Sample .purus files
├── moon.mod.json # MoonBit module definition
├── moon.mod # MoonBit module definition
└── package.json
```

Expand All @@ -42,7 +42,7 @@ node scripts/build.js
| `moon test` | Run all tests |
| `moon check` | Type check |
| `npm run build` | Full build (compile + copy) |
| `npm run sync` | Sync version to moon.mod.json |
| `npm run sync` | Sync version to moon.mod |

## Submitting Pull Requests

Expand Down
17 changes: 17 additions & 0 deletions moon.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name = "puruslang/purus"

version = "1.0.0"

import {
"moonbitlang/x@0.4.40",
}

readme = "README.md"

repository = "https://github.com/puruslang/purus"

license = "Apache-2.0"

keywords = [ "purus", "compiler", "altjs", "javascript" ]

description = "A language that compiles to JavaScript — no Shift key required"
17 changes: 0 additions & 17 deletions moon.mod.json

This file was deleted.

28 changes: 19 additions & 9 deletions scripts/sync-version.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Sync version from package.json to moon.mod.json
* Sync version from package.json to moon.mod
*/

const fs = require("fs");
Expand All @@ -8,16 +8,26 @@ const path = require("path");
const root = path.join(__dirname, "..");
const version = require(path.join(root, "package.json")).version;

const moonModPath = path.join(root, "moon.mod.json");
const moonMod = JSON.parse(fs.readFileSync(moonModPath, "utf8"));
const oldVersion = moonMod.version;
moonMod.version = version;
fs.writeFileSync(moonModPath, JSON.stringify(moonMod, null, " ") + "\n", "utf8");
const moonModPath = path.join(root, "moon.mod");
const content = fs.readFileSync(moonModPath, "utf8");

const versionLine = /^version\s*=\s*"([^"]*)"/m;
const match = content.match(versionLine);
if (!match) {
console.error("Error: no version field found in moon.mod");
process.exit(1);
}
const oldVersion = match[1];
fs.writeFileSync(
moonModPath,
content.replace(versionLine, `version = "${version}"`),
"utf8",
);

if (oldVersion !== version) {
console.log(`moon.mod.json: ${oldVersion} -> ${version}`);
console.log(`moon.mod: ${oldVersion} -> ${version}`);
} else {
console.log(`moon.mod.json: ${version} (no change)`);
console.log(`moon.mod: ${version} (no change)`);
}

console.log(`\nAll versions synced to ${version}`);
console.log(`\nAll versions synced to ${version}`);
10 changes: 5 additions & 5 deletions src/cmd/main/moon.pkg
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {
"puruslang/purus/src/lexer" @lexer,
"puruslang/purus/src/parser" @parser,
"puruslang/purus/src/codegen" @codegen,
"moonbitlang/x/sys" @sys,
"moonbitlang/x/fs" @fs,
"puruslang/purus/src/lexer",
"puruslang/purus/src/parser",
"puruslang/purus/src/codegen",
"moonbitlang/x/sys",
"moonbitlang/x/fs",
}

options(
Expand Down
13 changes: 13 additions & 0 deletions src/cmd/main/pkg.generated.mbti
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Generated using `moon info`, DON'T EDIT IT
package "puruslang/purus/src/cmd/main"

// Values

// Errors

// Types and methods

// Type aliases

// Traits

7 changes: 7 additions & 0 deletions src/codegen/moon.pkg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import {
"puruslang/purus/src/parser",
}

import {
"puruslang/purus/src/lexer",
} for "test"
8 changes: 0 additions & 8 deletions src/codegen/moon.pkg.json

This file was deleted.

26 changes: 26 additions & 0 deletions src/codegen/pkg.generated.mbti
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Generated using `moon info`, DON'T EDIT IT
package "puruslang/purus/src/codegen"

import {
"puruslang/purus/src/parser",
}

// Values

// Errors

// Types and methods
pub(all) struct JsCodegen {
buf : StringBuilder
mut indent_level : Int
mut private_fields : Array[String]
mut declared_vars : Array[String]
cjs : Bool
}
pub fn JsCodegen::generate(Self, Array[@parser.Stmt], header? : String, shebang? : String, strict? : Bool) -> String
pub fn JsCodegen::new(cjs? : Bool) -> Self

// Type aliases

// Traits

153 changes: 153 additions & 0 deletions src/lexer/pkg.generated.mbti
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
// Generated using `moon info`, DON'T EDIT IT
package "puruslang/purus/src/lexer"

import {
"moonbitlang/core/debug",
}

// Values

// Errors

// Types and methods
pub(all) struct Lexer {
chars : Array[Char]
mut pos : Int
mut line : Int
mut col : Int
mut tokens : Array[Token]
}
pub fn Lexer::new(String) -> Self
pub fn Lexer::tokenize(Self) -> Array[Token]

pub(all) struct Token {
kind : TokenKind
line : Int
col : Int
} derive(@debug.Debug)
pub impl Show for Token

pub(all) enum TokenKind {
Int(Int)
BigInt(String)
Float(Double)
Str(String)
Regex(String, String)
True_
False_
Ident(String)
Const_
Let_
Var_
Be
Add
Sub
Mul
Div
Fdiv
Mod
Neg
Pow
Eq
Neq
Lt
Gt
Le
Ge
And
Or
Not
Coal
Band
Bor
Bxor
Bnot
Shl
Shr
Ushr
Fn
Return_
To
If_
Elif
Else_
Unless
Then_
While_
Until
Do_
Yield_
For_
In_
Range_
Break_
Continue_
Match_
When_
Switch_
Case_
Pipe_
As
Of
Gives
Typeof_
Void_
Instanceof_
New_
Delete_
This_
Async_
Await_
Try_
Catch_
Finally_
Throw_
Import_
From_
Export_
Default_
Require_
Use_
Mod_
Public_
All_
Type_
With_
Class_
Extends_
Super_
Static_
Private_
Get_
Set_
Null_
Nil_
Undefined_
Nan_
Infinity_
List_
Object_
LBracket
RBracket
Comma
Semicolon
Dot
DotDot
DotDotDot
Backslash
OptDot
Newline
Indent(Int)
InterpStr(Array[String])
Blank
Shebang(String)
Comment(String)
BlockComment(String)
Eof
} derive(Eq, @debug.Debug)
pub impl Show for TokenKind

// Type aliases

// Traits

2 changes: 1 addition & 1 deletion src/parser/moon.pkg
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import {
"puruslang/purus/src/lexer" @lexer,
"puruslang/purus/src/lexer",
}
Loading
Loading