Skip to content

add documentation #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ For installation, refer to https://docs.soliditylang.org/en/latest/installing-so

## Examples

See `sample/READEME.md`.
See `sample/READEME.md`.

## Syntax

See `definition.md`.
55 changes: 55 additions & 0 deletions definition.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# 記法
シグネチャをつけたモジュールとして定義します.

## storage
シグネチャ内の1つ目に定義された型がstorage,2つ目に指定された型がmutable storageとして扱われます.
また,3つ目以降に型を定義することはできません.

## 定義可能な値
シグネチャ内に記述できる値は関数のみです.関数の第2引数は必須で,storageである必要があります.オプションでmutable storage型の第3引数をつけることができ,以降の引数はつけることはできません.返り値は2番目の要素にstorageを置いた2つ組のタプルである必要があります.

複数の値を入力として受け取る関数を書く場合はタプル型を使用します.


## 型
### unit型
`unit`: 可能な値は()です.

### bool型
`bool`: 可能な値は`true`と`false`です.

### uint型
符号なし整数(unsigned int)型
`uint`: `UInt`というコンストラクタを伴った符号なし整数.`UInt 1`など

### sint型
符号付き整数(signed int)型
`sint`: `SInt`というコンストラクタを伴った符号なし整数.`SInt 1`など

### address型
`address`: アドレスを表す型.

### タプル型
`t1 * t2 * ...`:`t1`, `t2`には実際の型が入ります.

### ハッシュテーブル型
`(t1, t2) Hashtbl.t`: `t1`, `t2`には実際の型が入り,`t1`から`t2`へのハッシュテーブル型となります.

## 式
使用可能な式は関数適用,let式,if式,逐次実行,一部のmatch式です.
let式で束縛する式としてunit型単体のものは使えません.代わりに逐次実行を使用してください.
逐次実行`e1; e2`の`e1`はunit型である必要があり,また,`()`のみの場合は使えません.
match式はtupleを分解する目的でのみ使えます.同様の操作をlet式でも可能です.


## 組み込み関数
### 演算子
関数として定義されています.
- `<`, `>`, `<=`, `>=`, `=`, `!=` : `'a -> 'a -> bool` 大小や等価性の比較
- `+`, `-`, `*`, `\`: `sint -> sint -> sint` sint型の演算子
- `+^`, `-^`, `*^`, `/^`: `uint -> uint -> uint` uint型の演算子

## その他関数
- `caller: unit -> address`: トランザクションを発行したアドレスを返します
- `Hashtbl.find: ('a, 'b) Hashtbl.t -> 'a -> 'b`: Hashtblライブラリ参照.
- `Hashtbl.replace: ('a, 'b) Hashtbl.t -> 'a -> 'b -> unit`: Hashtblライブラリを参照.
Loading