Skip to content

Release 0.3.0

らいパン粉 edited this page Oct 7, 2018 · 5 revisions

Release 0.3.0

タプル型

タプルを生成できるようにする。

空タプル
()

ペア
(4,5)

ネスト
(44,(3,2))

一つだけの要素のタプル
(8,)

関数の型指定

add::int->int->int;
add x y =x+y;

print_five::()->int;
print_five x = print 5;

外部関数宣言

C言語で書かれた外部の関数を宣言して使えるようにする。

現状では、print,scanという関数だけが外部からリンクされている。

ex print::int->int;
main= print 5;

型エラー時のエラーメッセージを出力できるように。

BNF

<program>       := {<stmt>} <skip_many>
<stmt>          := <skip_many> (
                        <infix> |
                        <def_func> |
                        <dec_func> |
                        <exturn_dec_func>
                   ) <skip_many> ';'
<def_func>      := <id> {<skip_many> <id>} <skip_many> '=' <skip_many> <expr>
<id>            := [a-z]{ [a-z] | [0-9] | '_' }
<expr>          := <expr_app> <skip_many> { <op> <skip_many> <expr_app> <skip_many> }
<expr_app>      := <term> {<skip_many> <term> }
<infix>         := ('infixr' | 'infixl') <space>+ <num> <space>+ <op>
<op>            := '+' | '-' | '/' | '*'
<term>          := <num> | <id> | <paren>
<paren>         := '(' <skip_many> <expr> ')'
<num>           := [0-9]+
<skip>          := '\n' | <space>
<skip_many>     := {<skip>}
<space>         := ' ' | '\t'
<ty_term>       := 'Int32'| <ty_paren> | <ty_func_pointer>
<ty_func_pointer>
                := 'Fn' <skip_many> <ty_func>
<ty_paren>      := '(' <skip_many> <ty_term> <skip_many> ')'
<ty_func>       := <ty_term> ( <skip_many> '->' <skip_many> <ty_term> )+
<dec_func>      := <id> <skip_many> '::' <skip_many> <ty_func>
<exturn_dec_func>
                := 'ex' <skip_many> <dec_func>

Clone this wiki locally