summaryrefslogtreecommitdiff
path: root/old/abc.ebnf
blob: 470f3f5d2da98d0570833cc9692a48a83684127d (plain)
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
27
28
29
30
31
32
33
34
35
36
Program 		= { Variable-Declaration | Function-Declaration | Function-Definition } .
Variable-Declaration	= Type Ident ";" .
Function-Declaration	= Type Ident "(" Function-Arguments ")" ";" .
Function-Definition	= Type Ident "(" Function-Arguments ")" Function-Body .
Function-Arguments	= [ Type Index { "," Type Ident } ] .
Type			= "int" | "char" .
Function-Body		= Statement .
Statement		= "{" Statement "}" 
			| Type Ident [ "=" Expression ] ";"
			| "return" Expression ";"
			| "if" "(" Expression ")" Statement [ "else" Statement ]
			| "while" "(" Expression ")" Statement
			| Expression ";" .
Expression		= Equal-Expression .
Equal-Expression	=

<expr> ::= <bitwise-expr> 
           | <bitwise-expr> = <expr>
<bitwise-expr> ::= <eq-expr>
                   | <bitwise-expr> & <eq-expr>
                   | <bitwise-expr> | <eq-expr>
<eq-expr> ::= <rel-expr>
              | <eq-expr> == <rel-expr>
              | <eq-expr> != <rel-expr>
<rel-expr> ::= <shift-expr>
               | <rel-expr> < <shift-expr>
<shift-expr> ::= <add-expr>
                 | <shift-expr> << <add-expr>
                 | <shift-expr> >> <add-expr>
<add-expr> ::= <postfix-expr>
               | <add-expr> + <postfix-expr>
               | <add-expr> - <postfix-expr>
<postfix-expr> ::= <prim-expr>
                   | <postfix-expr> [ <expr> ]
                   | <postfix-expr> ( <expr> { "," <expr> } )
<prim-expr> := <number> | <ident> | <string> | "(" <expr> ")"