Grammar extracted by Vadim Zaytsev, see the Grammar Zoo entry for details: c/c90/sdf/extracted
Source used for this grammar: Jurgen Vinju, Taeke Kooiker, Mark van den Brand, ansi-c/syntax/*.sdf
, February 2006 – December 2008 [GitHub]
TranslationUnit
, ExternalDeclaration
, FunctionDefinition
, Declaration
, InitDeclarator
, Specifier
, StructDeclaration
, StructDeclarator
, Enumerator
, Pointer
, Parameters
, MoreParameters
, Parameter
, TypeName
, Initializer
, D
, Expression
, LineDirective
, Flag
, Statement
), 0 root (—), 1 top (TranslationUnit
), 9 bottom (HexadecimalConstant
, Identifier
13, I
, IntegerConstant
2, StringConstant
2, AbstractDeclarator
2, Declarator
6, FloatingPointConstant
, CharacterConstant
).[linenum]
, [filename]
.TranslationUnit ::=
ExternalDeclaration
ExternalDeclaration ::= FunctionDefinition
ExternalDeclaration ::= Declaration
FunctionDefinition ::= Specifier"{" Declaration Statement "}"Declarator Declaration
Declaration ::= Specifier"," InitDeclarator ";"InitDeclarator
Declaration ::= Specifier";"
InitDeclarator ::= Declarator
InitDeclarator ::=
Declarator "=" Initializer
Specifier ::= Identifier
Specifier ::=
"typedef"
Specifier ::=
"extern"
Specifier ::=
"static"
Specifier ::=
"auto"
Specifier ::=
"register"
Specifier ::=
"void"
Specifier ::=
"char"
Specifier ::=
"short"
Specifier ::=
"int"
Specifier ::=
"long"
Specifier ::=
"float"
Specifier ::=
"double"
Specifier ::=
"signed"
Specifier ::=
"unsigned"
Specifier ::=
"const"
Specifier ::=
"volatile"
Specifier ::= "struct""union" Identifier "{" StructDeclaration "}"
Specifier ::= "struct""union" "{" StructDeclaration "}"
Specifier ::= "struct""union" Identifier
Specifier ::= "enum" "{" Enumerator "," Enumerator "}"
Specifier ::= "enum" Identifier "{" Enumerator "," Enumerator "}"
Specifier ::=
"enum" Identifier
StructDeclaration ::= Specifier"," StructDeclarator ";"StructDeclarator
StructDeclarator ::= Declarator
StructDeclarator ::=
":" Expression
StructDeclarator ::=
Declarator ":" Expression
Enumerator ::= Identifier
Enumerator ::=
Identifier "=" Expression
Pointer ::= "*" Specifier
Parameters ::= "," Parameter MoreParametersParameter
MoreParameters ::= "," "..."
Parameter ::=
Specifier
DeclaratorParameter ::=
Specifier
AbstractDeclaratorTypeName ::=
Specifier
AbstractDeclaratorInitializer ::= Expression
Initializer ::= "{" Initializer "," Initializer "," "}"
D ::= Pointer D
D ::= I
D ::= "(" D ")"
D ::= D "[" Expression "]"
D ::= D "(" Parameters ")"
D ::= D "(" Parameters ")"
D ::= D "[" Expression "]"
Expression ::= "__builtin_va_arg" "(" Expression "," TypeName ")"
LineDirective ::= "#" [linenum]::IntegerConstant [filename]::StringConstant Flag
Flag ::=
"1"
Flag ::=
"2"
Flag ::=
"3"
Flag ::=
"4"
ExternalDeclaration ::= LineDirective
Statement ::= LineDirective
StructDeclarator ::= LineDirective
Expression ::= "va_arg" "(" Expression "," TypeName ")"
Expression ::= Identifier
Expression ::= HexadecimalConstant
Expression ::= IntegerConstant
Expression ::= CharacterConstant
Expression ::= FloatingPointConstant
Expression ::= StringConstant
Expression ::= "(" Expression ")"
Expression ::= "sizeof" "(" TypeName ")"
Expression ::= Expression "[" Expression "]"
Expression ::= Expression "(" Expression "," Expression ")"
Expression ::=
Expression "." Identifier
Expression ::=
Expression "->" Identifier
Expression ::=
Expression "++"
Expression ::=
Expression "--"
Expression ::=
"++" Expression
Expression ::=
"--" Expression
Expression ::=
"&" Expression
Expression ::=
"*" Expression
Expression ::=
"+" Expression
Expression ::=
"-" Expression
Expression ::=
"~" Expression
Expression ::=
"!" Expression
Expression ::=
"sizeof" Expression
Expression ::= "(" TypeName ")" Expression
Expression ::=
Expression "*" Expression
Expression ::=
Expression "/" Expression
Expression ::=
Expression "%" Expression
Expression ::=
Expression "+" Expression
Expression ::=
Expression "-" Expression
Expression ::=
Expression "<<" Expression
Expression ::=
Expression ">>" Expression
Expression ::=
Expression "<" Expression
Expression ::=
Expression ">" Expression
Expression ::=
Expression "<=" Expression
Expression ::=
Expression ">=" Expression
Expression ::=
Expression "==" Expression
Expression ::=
Expression "!=" Expression
Expression ::=
Expression "=" Expression
Expression ::=
Expression "*=" Expression
Expression ::=
Expression "/=" Expression
Expression ::=
Expression "%=" Expression
Expression ::=
Expression "+=" Expression
Expression ::=
Expression "-=" Expression
Expression ::=
Expression "<<=" Expression
Expression ::=
Expression ">>=" Expression
Expression ::=
Expression "&=" Expression
Expression ::=
Expression "^=" Expression
Expression ::=
Expression "|=" Expression
Statement ::= "(" Statement ")" ";"
Specifier ::= "struct""union" Identifier "{" "}"
Statement ::= "{" Declaration Statement "}"
Statement ::=
Identifier ":" Statement
Statement ::= "case" Expression ":" Statement
Statement ::= "default" ":" Statement
Statement ::=
";"
Statement ::=
Expression ";"
Statement ::= "if" "(" Expression ")" Statement
Statement ::= "if" "(" Expression ")" Statement "else" Statement
Statement ::= "switch" "(" Expression ")" Statement
Statement ::= "while" "(" Expression ")" Statement
Statement ::= "do" Statement "while" "(" Expression ")" ";"
Statement ::= "for" "(" Expression ";" Expression ";" Expression ")" Statement
Statement ::= "goto" Identifier ";"
Statement ::= "continue" ";"
Statement ::= "break" ";"
Statement ::= "return" ";"
Statement ::= "return" Expression ";"