Skip to content
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

構文 #1

Open
kgtkr opened this issue Dec 18, 2019 · 1 comment
Open

構文 #1

kgtkr opened this issue Dec 18, 2019 · 1 comment

Comments

@kgtkr
Copy link
Owner

kgtkr commented Dec 18, 2019

予約語
i32
i64
f32
f64
string
bool
char
true
false
null
let
if
while
return
struct
fun
extern

type : i32 | i64 | f32 | f64 | string | [<type>] | bool | char | <ident>
ident:[a-zA-Z][a-zA-Z0-9_]*

expr : <parens> | <call> | <literal> | <calc> | <index> | <var> | <struct_ac>
var : <ident>
struct_ac:<expr>.<ident>
index : <expr>[<expr>]
prefix_op: ! | - | +
op : + | - | * | / | % | && | || | & | | | ^ | ** | == | < | <= | > | >=
literal : <struct_literal> | <i32_literal> | <i64_literal> | <f32_literal> | <f64_literal> | <string_literal> | <array_literal> | <bool_literal> | <char_literal> | <null_literal>
num:[0-9]+
int_literal:-?<num>
float_literal : -?<num>.<num>
array_literal : [<type>;<expr>]
struct_literal : <ident>{(<ident>:<expr>,)+}
string_literal : "<char>*"
boolean_literal : true | false
char_literal : '<char>'
null_literal : null
char : この余白はそれを書くには狭すぎる
call : <ident>((<expr>,)*)
parens : (<expr>)
calc : <expr><op><expr> | <prefix_op><expr>

stat: <block> | <expr2stat> | <let> | <return> | <while> | <if> | <set>
block: {(<stat>)*}
expr2stat: <expr>;
let: let <ident>:<type> = <expr>;
if: if(<expr>)<stat>
while: while(<expr>)<stat>
return: return <expr>?;
set: <set_ident>=<expr>;
set_ident:<ident>|<set_ident>.<ident>|<set_ident>[<expr>]

member: <function> | <struct> | <extern_function>
struct: struct <ident>{(<ident>:<type>,)*}
function:fun <ident>((<ident>:<type>,)*)(:<type>)? = <stat>
extern_function:extern fun <string_literal> <ident>((<ident>:<type>,)*)(:<type>)?
@kgtkr
Copy link
Owner Author

kgtkr commented Dec 18, 2019

メモ

構造体は全て参照型
配列も参照型
GCなんてない(やっぱり付けるかも)
最終的には型クラスもやってみたい
関数リテラル

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant