Grammar extracted by Vadim Zaytsev, see the Grammar Zoo entry for details: c/gnu/antoniol/extracted
Source used for this grammar: James R. Cordy, Antoniol et al heuristic to resolve all #ifs in C programs, version 2.0, November 2010
program
, line
, ifdef
, elsif_part
, else_part
, any_other_line
, not_newline
, long_comment
, ifdef_token
), 1 root (program
), 1 top (ifdef_token
), 8 bottom (token
, newline
6, comment
, elsifdef_line
2, other_preprocessor_line
, ifdef_line
2, elsedef_line
2, endifdef_line
2).program ::=
line
line ::= ifdef "//" other_preprocessor_line newline "//" any_other_line newline
ifdef ::= "//" ifdef_line newline line elsif_part else_part "//" endifdef_line newline
elsif_part ::= "//" elsifdef_line newline line
else_part ::= "//" elsedef_line newline line
any_other_line ::=
not_newline
not_newline ::= long_comment token
long_comment ::=
comment
ifdef_token ::= ifdef_line elsedef_line elsifdef_line endifdef_line