Grammar extracted by Vadim Zaytsev, see the Grammar Zoo entry for details: c/gnu/cordy-malton-dahn/extracted
Source used for this grammar: James R. Cordy, Andrew J. Malton, Christopher Dahn, TXL C Basis Grammar, Version 5.2, July 2011
program
, compilation_unit
, function_definition_or_declaration
, function_definition
, function_header
, preprocessor_function_header
, preprocessor
, KR_parameter_decls
, KR_simple_declaration
, KR_simple_type_name
, declaration
, extern_langauge_declaration
, null_declaration
, semi
, local_label
, decl_specifiers
, decl_qualifier_or_type_specifier
, nosemiNL
, struct_or_union_specifier
, struct_or_union_body
, member_declaration
, member_declarator
, sub_member_declarators
, attributes_or_asm
, attribute_spec
, acquires_releases
, attribute_specifier
, attribute_extension
, attribute_name
, attribute_arguments
, attribute_argument
, bitfieldsize
, decl_qualifier
, macro_specifier
, sc_specifier
, type_specifier
, typeof_expression
, expression_or_type_name
, typeof_specifier
, complex_specifier
, complex
, simple_type_or_qualifier
, type_qualifier
, bit_qualifier
, inline_qualifier
, init_qualifier
, exit_qualifier
, user_qualifier
, force_qualifier
, asmlinkage_qualifier
, zexport_qualifier
, simple_type_name
, type_id
, macro_type_arguments
, macro_type_argument
, struct_or_union
, enum_specifier
, enumerator
, enumerator_value
, extension_specifier
, weak_specifier
, declspec_specifier
, init_declarator
, declarator
, base_declarator
, declarator_extension
, function_declarator_extension
, array_declarator_extension
, ptr_operator
, nf_qualifier
, ptr_qualifier
, cv_qualifier
, restrict_qualifier
, type_name
, type_specifiers
, abstract_declarator
, argument_declaration_list
, argument_declaration
, comma_dotdotdot
, argument_declarator
, initialization
, initdata
, initializer
, initializer_unit
, colon_equals_or_equals
, compound_initializer
, dotdotdot
, element_label
, element_name_extension
, element_name
, preprocessor_list_initializer
, statement
, label
, label_id
, unlabeled_statement
, gnu_statement
, error_statement
, c_unlabeled_statement
, simple_statement_opt_semi
, structured_statement
, simple_statement
, null_statement
, compound_statement
, compound_statement_body
, declaration_or_statement
, expression_statement
, assign_assignment_expression
, comma_expression_statement
, if_statement
, sub_statement
, switch_statement
, else_statement
, else_sub_statement
, while_statement
, do_statement
, for_statement
, jump_statement
, asm_statement
, asm_spec
, asm_instruction_semi
, asm_instruction
, asm_unit
, token_or_key
, asm
, asm_template
, string_unit_NL
, asm_output_operands
, asm_input_operands
, asm_operand
, bracketed_id
, asm_clobbered_registers
, asm_register
, expression_list
, expression
, constant_expression
, assignment_expression
, unary_expression_assign
, assignment_operator
, conditional_expression
, conditional_operation
, logical_OR_expression
, OR_logical_AND_expression
, logical_OR_operator
, logical_AND_expression
, AND_inclusive_OR_expression
, logical_AND_operator
, inclusive_OR_expression
, OR_exclusive_OR_expression
, bit_OR_operator
, exclusive_OR_expression
, exclusive_OR_AND_expression
, bit_XOR_operator
, AND_expression
, AND_equality_expression
, bit_AND_operator
, equality_expression
, equality_relational_expression
, equality_operator
, relational_expression
, relational_shift_expression
, relational_operator
, shift_expression
, shift_additive_expression
, shift_operator
, additive_expression
, add_subtract_multiplicative_expression
, additive_operator
, multiplicative_expression
, multipy_divide_cast_expression
, multiplicative_operator
, cast_expression
, cast_operator
, unary_expression
, pre_increment_operator
, sub_unary_expression
, unary_operator
, sizeof_expression
, alignof_expression
, alignof_specifier
, postfix_expression
, primary
, reference_id
, compound_statement_expression
, constructor_expression
, constructor_type
, postfix_extension
, dotdot
, argument_expression
, colon_number
, constant
, gnu_long_int
, gnu_long_int_string
, gnu_long_int_charlit
, hexfloat
, string
, string_unit
, pseudo_string
, ps_name
, ps_arguments
, ps_argument_list
, ps_argument
, register_spec
, machinestart_declaration
, device_attr
, macro_declaration_or_statement
, reference_id_equals
, statement_declaration_or_end
, macro_call
, macro_arguments
, macro_argument
, equals_initializer
, macro_name
, upper_macro_name
, unknown_declaration_or_statement
, unknown_item
), 1 root (program
), 5 top (macro_type_arguments
, simple_statement_opt_semi
, compound_statement_expression
, device_attr
, statement_declaration_or_end
), 22 bottom (key
3, NL
38, SP
16, float
, long
, SPON
26, hex
2, id
16, upperlowerid
, token
3, dotfloat
, EX
15, SPOFF
12, whileeachid
3, number
2, integernumber
, TAB_1
, stringlit
4, IN
15, foreachid
2, preprocessor_line
, charlit
2).program ::= compilation_unit
compilation_unit ::=
function_definition_or_declaration
function_definition_or_declaration ::= function_definition declaration preprocessor compound_statement NL macro_declaration_or_statement unknown_declaration_or_statement
function_definition ::= NL function_header preprocessor_function_headerKR_parameter_decls compound_statement NL
function_header ::= decl_specifiers"YY_DECL" NLdeclarator function_declarator_extension attribute_spec
preprocessor_function_header ::= NL preprocessor function_header NL function_header
preprocessor ::= TAB_1 preprocessor_line NL
KR_parameter_decls ::=NL IN KR_simple_declaration EX
KR_simple_declaration ::= decl_specifiersKR_simple_type_name decl_specifiers declarator semi
KR_simple_type_name ::= simple_type_name struct_or_union id enum_specifier bit_qualifier
declaration ::= decl_specifiers "," semi decl_specifiers declarator "=" compound_initializer NL extern_langauge_declaration null_declaration local_label declarator asm_spec machinestart_declaration preprocessorinit_declarator
extern_langauge_declaration ::= "extern" stringlit "{" IN NL declaration EX "}" ";" NL
null_declaration ::= semi
semi ::=
";" NL
local_label ::=
"__label__"
decl_specifiers ::=
decl_qualifier_or_type_specifier
decl_qualifier_or_type_specifier ::=
decl_qualifier
type_specifier
macro_specifier nosemiNL
nosemiNL ::= NL
struct_or_union_specifier ::= struct_or_union attribute_specreference_id struct_or_union_body attribute_spec struct_or_union attribute_spec reference_id attribute_spec
struct_or_union_body ::= "{" IN NL member_declaration EX "}"
member_declaration ::= decl_specifiers "," semi null_declaration preprocessormember_declarator
member_declarator ::= declarator bitfieldsizesub_member_declarators attributes_or_asm bitfieldsize
sub_member_declarators ::= "(" member_declarator "," ")"
attributes_or_asm ::= attribute_spec asm_spec
attribute_spec ::= attribute_specifier "('(" attribute_extension "," ")')" IN NL acquires_releases "(" expression ")" EX upper_macro_name
acquires_releases ::= "__acquires" "__releases"
attribute_specifier ::= "__attribute__" "__attribute"
attribute_extension ::=
attribute_name attribute_arguments
attribute_name ::= id cv_qualifier
attribute_arguments ::= "(" attribute_argument ")"
attribute_argument ::= "(" attribute_argument ")" token_or_key
bitfieldsize ::=
":" constant_expression
decl_qualifier ::= sc_specifier type_qualifier extension_specifier weak_specifier declspec_specifier
macro_specifier ::= macro_call
sc_specifier ::= "auto" "register" "static" "extern" "far" "near" "typedef" "local" "vector" "const_debug" "INIT" "STATIC" "NEAR" "FAR"
type_specifier ::= simple_type_name enum_specifier struct_or_union_specifier typeof_expression complex_specifier
typeof_expression ::= typeof_specifier "(" expression_or_type_name ")"
expression_or_type_name ::= type_name expression
typeof_specifier ::= "__typeof" "typeof" "__typeof__" "typeof__"
complex_specifier ::=
complex simple_type_or_qualifier
complex ::= "__complex" "__complex__" "__Complex"
simple_type_or_qualifier ::= simple_type_name type_qualifier
type_qualifier ::= bit_qualifier cv_qualifier inline_qualifier restrict_qualifier init_qualifier exit_qualifier user_qualifier force_qualifier asmlinkage_qualifier zexport_qualifier attribute_spec
bit_qualifier ::= "long" "short" "signed" "unsigned" "__signed__" "__signed"
inline_qualifier ::= "__inline" "__inline__" "inline__" "inline" "SBA_INLINE"
init_qualifier ::= "__init" "init__" "init" "__init__"
exit_qualifier ::= "__exit" "exit__" "exit" "__exit__"
user_qualifier ::= "__user" "user__" "user" "__user__"
force_qualifier ::= "__force" "force__" "force" "__force__"
asmlinkage_qualifier ::=
"asmlinkage"
zexport_qualifier ::=
"ZEXPORT"
simple_type_name ::= "char" "int" "void" "float" "double" type_id
type_id ::= reference_id
macro_type_arguments ::= "(" macro_type_argument "," ")"
macro_type_argument ::= argument_expression
struct_or_union ::= "struct" "union"
enum_specifier ::= "enum" reference_id "enum" reference_id "{" enumerator "," "," preprocessor "}"
enumerator ::= preprocessorreference_id enumerator_value
enumerator_value ::=
"=" constant_expression
extension_specifier ::= "__extension__" "__extension"
weak_specifier ::= "__weak__" "__weak"
declspec_specifier ::= "__declspec" "(" decl_specifiers ")"
init_declarator ::= declarator attributes_or_asminitialization
declarator ::= attribute_specptr_operator base_declarator SPON declarator_extension attribute_spec
base_declarator ::= reference_id SPON "(" decl_specifiers declarator ")"
declarator_extension ::= function_declarator_extension array_declarator_extension
function_declarator_extension ::= "(" argument_declaration_list ")" cv_qualifier
array_declarator_extension ::= "[" constant_expression "]"
ptr_operator ::= nf_qualifier"*" SPOFF ptr_qualifier nf_qualifier "(" "*" ")" SPOFF ptr_qualifier
nf_qualifier ::= "near" "far" "NEAR" "FAR"
ptr_qualifier ::= SPON cv_qualifier SPON inline_qualifier SPON restrict_qualifier SPON init_qualifier SPON exit_qualifier SPON user_qualifier SPON zexport_qualifier
cv_qualifier ::= "const" "volatile" "CONST" "__const" "__const__" "const__" "__volatile__" "__volatile" "volatile__" "__iomem" initdata "internal_function" "yyconst" "pascal" upper_macro_name
restrict_qualifier ::= "__restrict" "restrict__" "restrict" "__restrict__"
type_name ::=
type_specifiers abstract_declarator
type_specifiers ::= type_qualifiertype_specifier type_qualifier type_qualifier
abstract_declarator ::= ptr_operator"(" abstract_declarator ")" declarator_extension "(" type_name ")" "static"declarator_extension SPON array_declarator_extension
argument_declaration_list ::= "," comma_dotdotdotargument_declaration
argument_declaration ::= decl_specifiers argument_declarator"(" argument_declaration ")"
comma_dotdotdot ::= "," SP "..." SP
argument_declarator ::= declarator attributes_or_asmabstract_declarator attributes_or_asm
initialization ::= initdata"=" initializer "(" constant_expression ")" macro_call
initdata ::= "__initdata" "__devinitdata" "__cpuinitdata" "__read_mostly" "__initmv" "__initdata_or_module" "__pminitdata" "__cpuinit" "__devinit" "BDATA" "compat_init_data" "in2000__INITDATA"
initializer ::= preprocessorinitializer_unit ε initializer_unit
initializer_unit ::= assignment_expression compound_initializer NL element_label colon_equals_or_equals";" NL "[" constant_expression dotdotdot constant_expression "]" "=" initializer ";" macro_callinitializer
colon_equals_or_equals ::= ":" "=" "|="
compound_initializer ::= "{" "}" "{" IN initializer "," "," ";" preprocessor_list_initializer EX NL "}"
dotdotdot ::=
SP "..." SP
element_label ::= "." element_name element_name_extension
element_name_extension ::= "." element_name "[" constant_expression "]"
element_name ::= id
preprocessor_list_initializer ::= preprocessor "," ","initializer
statement ::= preprocessorlabel unlabeled_statement label preprocessor
label ::= EX label_id ":" IN NL EX SP SP "case" constant_expression ":" IN NL EX SP SP "default" ":" IN NL EX SP SP "case" constant_expression SP "..." SP constant_expression ":" IN NL
label_id ::= id
unlabeled_statement ::= c_unlabeled_statement gnu_statement
gnu_statement ::= error_statement else_statement
error_statement ::= "error" ":" id "+" id semi
c_unlabeled_statement ::= simple_statement semi structured_statement
simple_statement_opt_semi ::=
simple_statement semi
structured_statement ::= if_statement for_statement while_statement switch_statement do_statement compound_statement asm_statement
simple_statement ::= jump_statement null_statement expression_statement
null_statement ::= ε
compound_statement ::= "{" IN NL compound_statement_body EX "}" ";" NL preprocessor
compound_statement_body ::=
declaration_or_statement
declaration_or_statement ::= declaration statement preprocessor function_definition macro_declaration_or_statement unknown_declaration_or_statement
expression_statement ::= pre_increment_operatorassignment_expression assign_assignment_expression comma_expression_statement
assign_assignment_expression ::= assignment_operator assignment_expression
comma_expression_statement ::=
"," expression_statement
if_statement ::= "if" "(" expression_list preprocessor ")" sub_statement else_statement "if" postfix_expression sub_statement else_statement
sub_statement ::= compound_statementIN NL statement EX IN NL macro_declaration_or_statement EX
switch_statement ::= "switch" "(" expression_list ")" sub_statement "switch" macro_call sub_statement
else_statement ::= preprocessor"else" else_sub_statement
else_sub_statement ::= if_statement sub_statement
while_statement ::= "while" "(" expression_list ")" sub_statement else_statement whileeachid "(" expression_list ")" sub_statement else_statement
do_statement ::= "do" sub_statement "while" "(" expression_list ")" semi "do" sub_statement "while" macro_call semi "do" sub_statement whileeachid "(" expression_list ")" semi
for_statement ::= "for" "(" expression_list ";" expression_list ";" expression_list ")" sub_statement "for" "(" decl_specifiers init_declarator ";" expression_list ";" expression_list ")" sub_statement "for" "(" expression_list ";" expression_list ")" sub_statement foreachid "(" expression_list ")" sub_statement
jump_statement ::= "goto" label_id "continue" "break" "return" expression "goto" ptr_operator expression "return" expression attribute_spec
asm_statement ::= asm_spec
asm_spec ::= asm cv_qualifier"(" IN asm_template asm_output_operands asm_input_operands asm_clobbered_registers EX ")" asm cv_qualifier "{" IN asm_instruction_semi asm_instruction semi EX "}"
asm_instruction_semi ::= asm_unit";" NL
asm_instruction ::=
asm_unit
NLasm_unit ::= token_or_key
token_or_key ::= token key
asm ::= "__asm__" "asm" "asm__" "__asm"
asm_template ::=
string_unit_NL
string_unit_NL ::= string_unit NL
asm_output_operands ::= ":" asm_operand "," NL
asm_input_operands ::= ":" asm_operand "," NL
asm_operand ::= bracketed_id"(" expression ")" pseudo_string "(" expression ")"string
bracketed_id ::= "[" id "]"
asm_clobbered_registers ::= ":" asm_register "," NL
asm_register ::= string pseudo_string
expression_list ::=
expression
expression ::= assignment_expression
constant_expression ::= conditional_expression
assignment_expression ::= conditional_expression unary_expression_assign assignment_expression
unary_expression_assign ::= unary_expression assignment_operator
assignment_operator ::= "=" "*=" "/=" "%=" "+=" "-=" ">>=" "<<=" "&=" "^=" "|="
conditional_expression ::=
logical_OR_expression conditional_operation
conditional_operation ::= "?" expression ":" conditional_expression
logical_OR_expression ::=
logical_AND_expression OR_logical_AND_expression
OR_logical_AND_expression ::= logical_OR_operator logical_AND_expression
logical_OR_operator ::= "||" "OR" "or"
logical_AND_expression ::=
inclusive_OR_expression AND_inclusive_OR_expression
AND_inclusive_OR_expression ::=
preprocessor
logical_AND_operator inclusive_OR_expressionlogical_AND_operator ::= "&&" "AND" "and" "ANDP"
inclusive_OR_expression ::=
exclusive_OR_expression OR_exclusive_OR_expression
OR_exclusive_OR_expression ::= bit_OR_operator exclusive_OR_expression
bit_OR_operator ::= "|" "BIT_OR" "bit_or"
exclusive_OR_expression ::=
AND_expression exclusive_OR_AND_expression
exclusive_OR_AND_expression ::= bit_XOR_operator AND_expression
bit_XOR_operator ::= "^" "BIT_XOR" "bit_xor"
AND_expression ::=
equality_expression AND_equality_expression
AND_equality_expression ::= bit_AND_operator equality_expression
bit_AND_operator ::= "&" "BIT_AND" "bit_and"
equality_expression ::=
relational_expression equality_relational_expression
equality_relational_expression ::= equality_operator relational_expression
equality_operator ::= "==" "!="
relational_expression ::=
shift_expression relational_shift_expression
relational_shift_expression ::= relational_operator shift_expression
relational_operator ::= "<" ">" "<=" ">="
shift_expression ::=
additive_expression shift_additive_expression
shift_additive_expression ::= shift_operator additive_expression
shift_operator ::= "<<" ">>"
additive_expression ::=
multiplicative_expression add_subtract_multiplicative_expression
add_subtract_multiplicative_expression ::= additive_operator multiplicative_expression
additive_operator ::= "+" "-"
multiplicative_expression ::=
cast_expression multipy_divide_cast_expression
multipy_divide_cast_expression ::= multiplicative_operator cast_expression
multiplicative_operator ::= "*" "/" "%" "DIV" "MOD"
cast_expression ::=
cast_operator
unary_expressioncast_operator ::= "(" type_name ")"
unary_expression ::=
pre_increment_operator
sub_unary_expression SPONpre_increment_operator ::= "++" SPOFF "--" SPOFF
sub_unary_expression ::= postfix_expression unary_operator SPOFF cast_expression SPON SPON sizeof_expression SPON alignof_expression
unary_operator ::= "&" "*" "+" "-" "~" "!" "&&" "NOT" "not"
sizeof_expression ::= "sizeof" "(" type_name ")" "sizeof" unary_expression
alignof_expression ::= alignof_specifier "(" expression_or_type_name ")"
alignof_specifier ::= "__alignof__" "__alignof"
postfix_expression ::=
primary SPOFF postfix_extension
SPONprimary ::= reference_id constant string "(" SPON expression_list "," ")" "{" SPON expression_list "," "}" SPON extension_specifier "(" expression_list ")" SPON constructor_expression SPON asm_spec
reference_id ::= id foreachid whileeachid
compound_statement_expression ::= "(" compound_statement ")"
constructor_expression ::= "(" constructor_type ")" "{" initializer "," "," "}" "(" constructor_expression ")"
constructor_type ::= struct_or_union_specifier type_specifiers ptr_operatorarray_declarator_extension
postfix_extension ::= "[" SPON assignment_expression SPOFF "]" SP "(" SPON argument_expression "," dotdot SPOFF ")" "." id "->" id macro_call "++" "--"
dotdot ::=
SP ".." SP
argument_expression ::= preprocessor"do" "extern" "continue" εid assignment_expression id colon_number preprocessor type_name structured_statement equality_operator relational_operator assignment_operator assignment_expression
colon_number ::=
":" number
constant ::= number float hex long SP dotfloat charlit string gnu_long_int gnu_long_int_string hexfloat
gnu_long_int ::= gnu_long_int_string gnu_long_int_charlit
gnu_long_int_string ::=
"L" SPOFF string SPON
gnu_long_int_charlit ::=
"L" SPOFF charlit SPON
hexfloat ::= extension_specifier hex
string ::= stringlit string_unitpseudo_string stringlit string_unit
string_unit ::= stringlit pseudo_string register_spec preprocessor
pseudo_string ::=
ps_name ps_arguments
ps_name ::= id
ps_arguments ::= "(" ps_argument_list ")"
ps_argument_list ::= ","ps_argument
ps_argument ::= constant_expression register_spec
register_spec ::= "%" SPOFF "%" id SPON "%" SPOFF "%" integernumber id SPON
machinestart_declaration ::= "MACHINE_START" "(" expression_list ")" IN initializer "," "," EX NL "MACHINE_END" ";" NL
device_attr ::= "DEVICE_ATTR" "SYSDEV_ATTR" "DEFINE_TIMER" "DECLARE_TASKLET"
macro_declaration_or_statement ::= reference_id_equals";" NL upper_macro_name ";" NLmacro_call equals_initializer
reference_id_equals ::=
reference_id "="
statement_declaration_or_end ::=
declaration_or_statement
"}"
macro_call ::= macro_name "(" macro_arguments ")"
macro_arguments ::=
macro_argument
macro_argument ::= "(" macro_arguments ")" token key
equals_initializer ::=
"=" initializer
initializer
macro_name ::= id
upper_macro_name ::= upperlowerid
unknown_declaration_or_statement ::= unknown_item";" NL unknown_item NL
unknown_item ::= "{" unknown_item "}" token key