-
Notifications
You must be signed in to change notification settings - Fork 4
Release 0.3.0
らいパン粉 edited this page Oct 19, 2018
·
5 revisions
タプルを生成できるようにする。
空タプル
()
ペア
(4,5)
ネスト
(44,(3,2))
一つだけの要素のタプル
(8,)
add::Int32->Int32->Int32;
add x y =x+y;
print_five::()->Int32;
print_five x = print 5;
hoge::(Fn Int32->Int32)->Int32;
hoge f = f 5 + 1;
C言語で書かれた外部の関数を宣言して使えるようにする。
現状では、print,scanという関数だけが外部からリンクされている。
ex print::int->int;
main= print 5;
<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> | <tuple>
<paren> := '(' <skip_many> <expr> ')'
<num> := [0-9]+
<tuple> := '(' <skip_many> [<expr> {',' <skip_many> <expr>} [',' <skip_many>]] ')'
<skip> := '\n' | <space>
<skip_many> := {<skip>}
<space> := ' ' | '\t'
<ty_term> := 'Int32'| <ty_paren> |<ty_tuple>| <ty_func_pointer>
<ty_func_pointer>
:= 'Fn' <skip_many> <ty_func>
<ty_paren> := '(' <skip_many> <ty_term> <skip_many> ')'
<ty_tuple> := '(' <skip_many> [<ty_term> <skip_many> {',' <skip_many> <ty_term> <skip_many>} [',' <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>