-
Notifications
You must be signed in to change notification settings - Fork 0
/
grammar
26 lines (26 loc) · 976 Bytes
/
grammar
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<program> ::= <function> {<endl> <function>} {<endl> <operator>}
<function> ::= <prototype> <assert> <stmt>
<prototype> ::= <ident> <open-brack> <ident> {<delimiter> <ident>}<close-brack>
<stmt> ::= <exp> {<impl> <exp>}
<exp> ::= <term> {<sum> <term>}
<term> ::= <factor> {<mul> <factor>}
<factor> ::= <unary> <factor> |
<paren> |
<ident> |
<digit>
<paren> ::= <open-brack> <stmt> <close-brack>
<unary> ::= <not> | <inc> | <dec>
<not> ::= "~"
<inc> ::= "++"
<dec> ::= "--"
<endl> ::= "\n"
<assert> ::= ":="
<open-brack> ::= "("
<delimiter> ::= ","
<close-brack> ::= ")"
<impl> ::= "->" | "+>"
<sum> ::= "|" | "#" | "+" | "-"
<mul> ::= "&" | "*"
<ident> ::= "[a-z][_a-zA-Z0-9]*"
<ident> ::= "[a-zA-Z][_a-zA-Z0-9]*"
<digit> ::= "$" | "-?[0-1]"