EBNF Grammar
external-declaration
:
function-prototype
function-definition
declaration
function-prototype
:
type-specifier
declarator
;
function-definition
:
type-specifier
declarator
compound-statement
declarator
:
identifier
parameter-list
parameter-list
:
(
parameter-declaration-list
opt )
parameter-declaration-list
:
parameter-declaration
parameter-declaration
, parameter-declaration-list
parameter-declaration
:
type-specifier
identifier
compound-statement
:
{
statement-list
opt }
statement-list
:
statement
statement
statement-list
statement
:
declaration
expression-statement
if-statement
iteration-statement
declaration
:
type-specifier
identifier
;
expression-statement
:
expression
;
expression
:
assignement-expression
assignement-expression
:
binary-expression
identifier
assignment-operator
assignement-expression
unary-expression
function-call
binary-expression
:
number
binary-operator
( expression
| number
)
binary-operator
: +
-
*
/
%
==
!=
<
<=
>
>=
assignment-operator
: =
*=
/=
%=
+=
-=
unary-expression
:
identifier
unary-operator
unary-operator
: ++
--
if-statement
:
if (
expression
)
statement
if (
expression
)
statement
else
statement
iteration-statement
:
while (
expression
)
statement
for
(
init-expression
opt ;
cond-expression
opt ;
loop-expression
opt )
statement
function-call
:
identifier
(
argument-list
)
argument-list
:
number
identifier
function-call
type-specifier
: void
int
long
float
identifier
:
[a-zA-Z_][a-zA-Z0-9_]*
number
:
[+|-]?[0-9]+
[+|-]?[0-9]+.[0-9]+
Last updated