Skip to content

Commit

Permalink
v0.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
marihachi authored Apr 4, 2023
2 parents 8450691 + 98de99b commit 0eeaa0a
Show file tree
Hide file tree
Showing 46 changed files with 3,599 additions and 1,238 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ jobs:

strategy:
matrix:
node-version: [18.14.2]
node: [16, 18]

steps:
- uses: actions/checkout@v3

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
- name: Setup Node.js ${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
node-version: ${{ matrix.node }}

- uses: actions/cache@v3
with:
Expand Down
38 changes: 38 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,44 @@
-->

## 0.8.0 (2023/04/04)

- 構造体のサポート。
- 配列のサポート。
- 文字型と文字リテラルのサポート。
- 意味解析エラー検出処理の改善。
- ビルトイン関数をリニューアルしました。(詳細は下記)
- CLI: 段階的にプロジェクト機能をサポート。
- JavaScript APIでソースコードを直接実行する機能の廃止。
- CLI: `run`コマンドに`--check-skip`オプションが追加されました。
- CLI: `check`コマンドが追加されました。
- CLI: `new`コマンドが追加されました。
- 意味解析のバグ修正。
- CLI: バージョン情報が表示できない問題を修正。

### ビルトイン関数のリニューアル

以下のビルトイン関数が追加されました。
- `number.parse`
- `char.fromNumber`
- `char.toNumber`
- `char.toString`
- `string.fromChars`
- `string.toChars`
- `array.insert`
- `array.add`
- `array.removeAt`
- `array.count`
- `console.read`

以下のビルトイン関数の名前が変更になりました。
- `toString` -> `number.toString`
- `assertEqNum` -> `number.assertEq`
- `concatStr` -> `string.concat`
- `assertEqStr` -> `string.assertEq`
- `printStr` -> `console.write`
- `printNum` -> `console.writeNum`

## 0.7.0 (2023/03/13)

- 実装がRustからNode.jsに移行されました。
Expand Down
46 changes: 32 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<img alt="uguisu logo" width="100px" align="right" src="https://raw.githubusercontent.com/uguisu-dev/uguisu/v0.7.0/uguisu-logo.png" />
<img alt="uguisu logo" width="100px" align="right" src="https://raw.githubusercontent.com/uguisu-dev/uguisu/v0.8.0/uguisu-logo.png" />

# Uguisu
The Uguisu is a statically typed scripting language.
Expand All @@ -16,13 +16,13 @@ fn calc(x: number): number {
fn main() {
var value = 10;
printNum(calc(value));
console.writeNum(calc(value));
}
```

## Syntaxes
- English (Not translated yet.)
- [日本語](https://github.com/uguisu-dev/uguisu/blob/v0.7.0/docs/syntaxes_ja.md)
- [日本語](https://github.com/uguisu-dev/uguisu/blob/v0.8.0/docs/syntaxes_ja.md)

## Install
Node.js and npm installation is required.
Expand All @@ -36,7 +36,10 @@ $ npm i -g uguisu-js
Usage: uguisu [options] [commands]
Examples:
uguisu run <filename>
uguisu new <projectDir>
uguisu run <projectDir>
uguisu check <projectDir>
uguisu run --skip-check <projectDir>
uguisu <command> -h
uguisu -v
Expand All @@ -45,10 +48,22 @@ Options:
-v, --version Print Uguisu version.
Commands:
run Run a script file.
new Create a new uguisu project.
run Run a uguisu project.
check Perform the check for a project.
```

The following command creates a project.
```
$ uguisu new ./my-project
```

The following command runs the project. A code check is also performed before execution.
```
$ uguisu run ./my-project
```

## JavaScript API
Uguisu only supports the ES Modules (ESM).

Expand All @@ -61,16 +76,19 @@ const uguisu = new Uguisu({
}
});

// Run passing a source code.
const sourceCode = `
fn main() {
printStr("hello world");
}
`;
uguisu.runCode(sourceCode);
const projectDir = './your-project';

// Check code and Run
uguisu.run(projectDir);
```

Code checking and running can also be separated:
```js
// Check code
uguisu.check(projectDir);

// Run passing a file path of a source code.
uguisu.runFile('./example.ug');
// Run
uguisu.run(projectDir, { skipCheck: true });
```

## License
Expand Down
6 changes: 6 additions & 0 deletions docs/design-sketch/array.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- 配列の型は推論できる。
- どのように推論するか考え中

```
var x: number[] = [1, 2, 3];
```
54 changes: 54 additions & 0 deletions docs/design-sketch/defined-structure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
```
interface Position {
fn getX(): number;
fn getY(): number;
}
interface Drawable {
fn draw();
}
struct Player {
name: string,
x: number,
y: number,
}
impl Player {
fn getName(): number {
return this.name;
}
}
impl Player : Position {
fn getX(): number {
return this.x;
}
fn getY(): number {
return this.y;
}
}
impl Player : Drawable {
fn draw() {
// ...
}
}
fn showCharInfo(char: Position & Drawable) {
print(char.getX());
print(char.getY());
print(char.draw());
}
fn main() {
var player = new Player {
name: "you",
x: 0,
y: 0,
};
console.write(player.getName());
showCharInfo(player);
}
```
15 changes: 15 additions & 0 deletions docs/design-sketch/function.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
- 関数宣言
- 引数の型は明示しなければならない。
- 戻り値の型は明示しなければならない。
- 指定されない場合は`void`型として扱われる。
- (静的解析) 指定した戻り値の型の値が返されない場合はエラーとする。

```
fn add(x: number, y: number): number {
return x + y;
}
fn main() {
var x: number = add(1, 2);
}
```
32 changes: 32 additions & 0 deletions docs/design-sketch/operator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## 二項演算子
- 演算子の左側の式から型を推論する。

```
var x: number = 1 + 2;
// 3
```

```
var x: bool = (1 == 1);
// true
```

```
var x: bool = (1 < 2);
// true
```

```
var x: bool;
x = (true && true);
// true
x = (true || false);
// true
```
- `e1 || e2`の演算でe1を評価した結果がtrueの場合はe2の評価は行われない。

## 単項演算子
```
var x: bool = !true;
// false
```
6 changes: 6 additions & 0 deletions docs/design-sketch/tupple.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- タプルの型は推論できる。
- タプルの要素数、各要素から型を推論する。

```
var x: (number, number) = (1, 2);
```
21 changes: 21 additions & 0 deletions docs/design-sketch/variable.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
- 変数の型は推論できる。
- 初期値として与えられた式の型を推論して、変数の型とする。

宣言・代入
```
var x: number = 1;
x = 2;
```
```
var x: number;
x = 1;
```
```
var x;
x = 1;
```

参照
```
console.writeNum(x);
```
Loading

0 comments on commit 0eeaa0a

Please sign in to comment.