Thanks to visit codestin.com
Credit goes to github.com

Skip to content

hsk/camlup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Camlup

Camlup

http://www.afghanistan-today.org/article/?id=814

CamlupはOCamlへのトランスレータ言語です。

Camlupを使う事でC言語ライクな文法でOCamlのプログラムを記述出来ます。

ビルド&インストール

Mac OSX

あらかじめ、OCamlをインストールしておきます。

ビルド

ocamlとUnix環境のmakeがある環境で以下のコマンドを実行します。

$ make

と入力します。

インストール

$ make install

と実行すると、/usr/local/binにnmlcがコピーされインストールが完了します。

Windows

  1. OCamlをインストールします。
  2. nmlc.exeを以下のURLからダウンロードして、パスを通します。

https://github.com/hsk/camlup/blob/master/nmlc.exe?raw=true

※新しいWindowsの場合は認証が必要です。 問題は無いはずですが、ウィルスチェックを行ってから実行してください。 プログラムはソースを読み込みmlファイルを出力し、ocamlを実行するのみです。

Hello World

open Printf
printf("hello world!\n")

hello.nml

$ ./nmlc -run examples/hello.nml
hello world!

特徴

  • 美しいカリー化された関数の定義、呼び出し
  • ネイティブなコンパイル
  • 高速コンパイル
  • 高速な処理系のビルド

以下のように関数f5を定義して、呼び出す事が出来ます:

f5 = {
 | a b c d e => a + b + c + d + e
}

printf("%d\n" f5(1 2 3 4 5))

この関数をOCamlで書くと以下のようになります:

let f5 = (
  fun a b c d e -> a + b + c + d + e
)
printf "%d\n" (f5 1 2 3 4 5)

タプルを使った関数

f = {
 | a,b => a + b
}
printf("%d\n")(f(1,2))
printf("%d\n" f(1,2))

タプルを2つ受け取るカリー化関数

f2 = {
  | a,b c,d => a*b + c*d
}
printf("%d\n")(f2(1,2)(3,4))
printf("%d\n" f2(1,2 3,4))

実装状況

  • リテラル
    • 文字列
    • 整数
    • 浮動小数点数
    • 文字列のエスケープシーケンス
    • 文字
  • 変数
  • if else 式
  • match 式
    • int,string,list,variant,tuple
    • ネストしたマッチ
    • match式のas
  • for,while式
  • パーシャルファンクション
  • 配列
    • 値設定
    • リテラル?コンストラクタ?
    • 値取得
  • レコード
  • 代数データ型
    • 大まかな機能
    • 型パラメータ
    • mutableなフィールド
    • 値の設定
  • ブロック
  • 名前付き引数
  • オブジェクト指向
    • とりあえず動かす
    • private
    • mutable
  • モジュール
    • とりあえず動かす
    • Map等が使えるようにする
    • シグニチャ
  • 行番号の埋め込み
    • 宣言
    • より詳細に
  • その他
    • バージョン管理する
    • リリースバージョンを作成する
    • 全般的なテスト
    • ドキュメント
      • windowsについて
      • dexpとrmlについて
    • チュートリアル
    • makeとmake install を分ける

サンプル

シンプルなサンプル

詳細な動作

examples/test.nmlとその変換結果examples/test.ml を参考にしてください。

ドキュメント

License

MIT Licence

About

camlup is another c like ocaml syntax language

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages