Grammar extracted by Vadim Zaytsev, see the Grammar Zoo entry for details: c/c90/rascal/extracted
Source used for this grammar: Arnold Lankamp, lang::c90::syntax::C
, 2011 [GitHub]
StructDeclarator
, PrototypeParameter
, TypeSpecifier
, StructDeclaration
, TypeName
, Initializer
, InitDeclarator
, Statement
, ExternalDeclaration
, PrototypeParameters
, Parameters
, FunctionPrototype
, Parameter
, AnonymousIdentifier
, PrototypeDeclarator
, AbstractDeclarator
, Declarator
, Specifier
, StorageClass
, Declaration
, Enumerator
, NonCommaExpression
, FunctionDefinition
, GlobalDeclaration
, TranslationUnit
, TypeQualifier
, MoreParameters
, Expression
), 0 root (—), 1 top (TranslationUnit
), 6 bottom (HexadecimalConstant
, Identifier
16, IntegerConstant
, StringConstant
, FloatingPointConstant
, CharacterConstant
).[StructDecl]
, [Union]
, [Int]
, [Void]
, [StructAnonDecl]
, [Short]
, [Identifier]
4, [EnumDecl]
, [UnionDecl]
, [UnionAnonDecl]
, [Enum]
, [Struct]
, [Long]
, [Double]
, [Float]
, [EnumAnonDecl]
, [Char]
, [specs]
8, [StructDeclWithoutDecl]
, [StructDeclWithDecl]
, [decl]
15, [DefaultFunctionPrototype]
, [params]
3, [FunctionDeclarator]
3, [Bracket]
4, [exp]
4, [ArrayDeclarator]
3, [qualifiers]
3, [PointerDeclarator]
3, [StorageClass]
, [TypeQualifier]
, [TypeSpecifier]
, [TypeDef]
, [DeclarationWithoutInitDecls]
, [initDeclarators]
2, [DeclarationWithInitDecls]
, [expr]
, [NonCommaExpression]
, [DefaultFunctionDefinition]
, [GlobalDeclarationWithoutInitDecls]
, [GlobalDeclarationWithInitDecls]
, [Variable]
, [SizeOfExpression]
, [lexp]
, [rexp]
, [MultiplicationExpression]
, [CommaExpression]
.StructDeclarator ::= Declarator
StructDeclarator ::= Declarator":" Expression
PrototypeParameter ::=
Specifier
AbstractDeclaratorTypeSpecifier ::= [StructDecl]::"struct" Identifier "{" StructDeclaration "}"
TypeSpecifier ::= [Union]::"union" Identifier
TypeSpecifier ::=
[Int]::"int"
TypeSpecifier ::=
[Void]::"void"
TypeSpecifier ::= [StructAnonDecl]::"struct" "{" StructDeclaration "}"
TypeSpecifier ::=
[Short]::"short"
TypeSpecifier ::= [Identifier]::Identifier
TypeSpecifier ::= [EnumDecl]::"enum" Identifier "{" Enumerator "," "}"
TypeSpecifier ::=
"signed"
TypeSpecifier ::= [UnionDecl]::"union" Identifier "{" StructDeclaration "}"
TypeSpecifier ::= [UnionAnonDecl]::"union" "{" StructDeclaration "}"
TypeSpecifier ::= [Enum]::"enum" Identifier
TypeSpecifier ::= [Struct]::"struct" Identifier
TypeSpecifier ::=
"unsigned"
TypeSpecifier ::=
[Long]::"long"
TypeSpecifier ::=
[Double]::"double"
TypeSpecifier ::=
[Float]::"float"
TypeSpecifier ::= [EnumAnonDecl]::"enum" "{" Enumerator "," "}"
TypeSpecifier ::=
[Char]::"char"
StructDeclaration ::= [StructDeclWithoutDecl]::";"[specs]::Specifier
StructDeclaration ::= [StructDeclWithDecl]::"," ";"[specs]::Specifier StructDeclarator
TypeName ::=
Specifier
AbstractDeclaratorInitializer ::= "{" Initializer "," "," "}"
Initializer ::= NonCommaExpression
InitDeclarator ::=
[decl]::Declarator "=" Initializer
InitDeclarator ::= [decl]::Declarator
Statement ::= "default" ":" Statement
Statement ::= "switch" "(" Expression ")" Statement
Statement ::= "return" ";"
Statement ::= "for" "(" Expression ";" Expression ";" Expression ")" Statement
Statement ::= "case" Expression ":" Statement
Statement ::= "continue" ";"
Statement ::=
";"
Statement ::= "goto" Identifier ";"
Statement ::= "do" Statement "while" "(" Expression ")" ";"
Statement ::= "{" Declaration Statement "}"
Statement ::= "while" "(" Expression ")" Statement
Statement ::= "break" ";"
Statement ::= "if" "(" Expression ")" Statement
Statement ::=
Identifier ":" Statement
Statement ::=
Expression ";"
Statement ::= "if" "(" Expression ")" Statement "else" Statement
Statement ::= "return" Expression ";"
ExternalDeclaration ::= FunctionPrototype
ExternalDeclaration ::= FunctionDefinition
ExternalDeclaration ::= GlobalDeclaration
PrototypeParameters ::=
"void"
PrototypeParameters ::= "," MoreParametersPrototypeParameter
Parameters ::= "," MoreParametersParameter
Parameters ::=
"void"
FunctionPrototype ::= [DefaultFunctionPrototype]::";"[specs]::Specifier [decl]::PrototypeDeclarator
Parameter ::=
Specifier
DeclaratorAnonymousIdentifier ::= ε
PrototypeDeclarator ::= [FunctionDeclarator]::"(" [params]::PrototypeParameters ")"[decl]::PrototypeDeclarator
PrototypeDeclarator ::= [Identifier]::Identifier
PrototypeDeclarator ::= [Bracket]::"(" [decl]::AbstractDeclarator ")"
PrototypeDeclarator ::= [ArrayDeclarator]::"[" [exp]::Expression "]"[decl]::PrototypeDeclarator
PrototypeDeclarator ::= [PointerDeclarator]::"*" [qualifiers]::TypeQualifier [decl]::PrototypeDeclarator
AbstractDeclarator ::= [Identifier]::AnonymousIdentifier
AbstractDeclarator ::= [ArrayDeclarator]::"[" [exp]::Expression "]"[decl]::AbstractDeclarator
AbstractDeclarator ::= [Bracket]::"(" [decl]::AbstractDeclarator ")"
AbstractDeclarator ::= [FunctionDeclarator]::"(" [params]::Parameters ")"[decl]::AbstractDeclarator
AbstractDeclarator ::= [PointerDeclarator]::"*" [qualifiers]::TypeQualifier [decl]::AbstractDeclarator
Declarator ::= [ArrayDeclarator]::"[" [exp]::Expression "]"[decl]::Declarator
Declarator ::= [Identifier]::Identifier
Declarator ::= [FunctionDeclarator]::"(" [params]::Parameters ")"[decl]::Declarator
Declarator ::= [Bracket]::"(" [decl]::Declarator ")"
Declarator ::= [PointerDeclarator]::"*" [qualifiers]::TypeQualifier [decl]::Declarator
Specifier ::= [StorageClass]::StorageClass
Specifier ::= [TypeQualifier]::TypeQualifier
Specifier ::= [TypeSpecifier]::TypeSpecifier
StorageClass ::=
"register"
StorageClass ::=
"static"
StorageClass ::=
"extern"
StorageClass ::=
"auto"
StorageClass ::=
[TypeDef]::"typedef"
Declaration ::= [DeclarationWithoutInitDecls]::";"[specs]::Specifier
Declaration ::= [DeclarationWithInitDecls]::"," ";"[specs]::Specifier [initDeclarators]:: InitDeclarator
Enumerator ::= Identifier
Enumerator ::=
Identifier "=" NonCommaExpression
NonCommaExpression ::= [NonCommaExpression]::[expr]::Expression
FunctionDefinition ::= [DefaultFunctionDefinition]::"{" Declaration Statement "}"[specs]::Specifier Declarator Declaration
GlobalDeclaration ::= [GlobalDeclarationWithoutInitDecls]::";"[specs]::Specifier
GlobalDeclaration ::= [GlobalDeclarationWithInitDecls]::"," ";"[specs]::Specifier [initDeclarators]:: InitDeclarator
TranslationUnit ::=
ExternalDeclaration
TypeQualifier ::=
"const"
TypeQualifier ::=
"volatile"
MoreParameters ::= "," "..."
Expression ::= CharacterConstant
Expression ::=
Expression "--"
Expression ::= [Variable]::Identifier
Expression ::= Expression "[" Expression "]"
Expression ::= [Bracket]::"(" Expression ")"
Expression ::= "sizeof" "(" TypeName ")"
Expression ::=
Expression "++"
Expression ::= FloatingPointConstant
Expression ::=
Expression "." Identifier
Expression ::= StringConstant
Expression ::= IntegerConstant
Expression ::= HexadecimalConstant
Expression ::=
Expression "->" Identifier
Expression ::= Expression "(" NonCommaExpression "," ")"
Expression ::= Expression
Expression ::= [SizeOfExpression]::"sizeof" [exp]::Expression
Expression ::=
"&" Expression
Expression ::=
"!" Expression
Expression ::= "(" TypeName ")" Expression
Expression ::=
"*" Expression
Expression ::=
"+" Expression
Expression ::=
"-" Expression
Expression ::=
"~" Expression
Expression ::= [MultiplicationExpression]::"*" [rexp]::Expression[lexp]::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 ">>=" Expression
Expression ::=
Expression "^=" Expression
Expression ::=
Expression "-=" Expression
Expression ::=
Expression "<<=" Expression
Expression ::=
Expression "%=" Expression
Expression ::=
Expression "=" Expression
Expression ::= [CommaExpression]::"," ExpressionExpression