Grammar extracted by Vadim Zaytsev, see the Grammar Zoo entry for details: pascal/delphi/preprocessor/cangas/extracted
Source used for this grammar: Jorge L. Cangas, TXL Grammar for Borland Delphi 2006 preprocessor, delphipp.grammar
, December 2007
ident
, namespace
, nested_id
, filenamelit
, delphipp_file
, pp_stmt_or_water
, pp_comment
, cmbracketblock
, cmstarblock
, bracketbody
, starbody
, cmline
, cmlinebody
, pp_any
, codetoken
, pp_stmt
, pp_directivestmt
, pp_directive
, pp_align
, pp_minenumsize
, pp_switch
, pp_switchopt
, pp_ifstmt
, pp_ifblock
, pp_content
, pp_elseifblock
, pp_ifexpr
, pp_elseifexpr
, pp_endif
, if_alt
, else_alt
, endif_alt
, pp_boolexpr
, boolfunc
, booleanlit
, pp_litexpr
, pp_boolopr
, pp_compareopr
, anynumber
), 0 root (—), 3 top (delphipp_file
, pp_boolopr
, pp_compareopr
), 11 bottom (id
16, token
, space
48, stringlit
, hexnumber
, EOL
, key
2, SPON
, SPOFF
, number
, charlit
9).ident ::= id key
namespace ::=
id "."
nested_id ::=
SPOFF namespace
ident SPONfilenamelit ::= charlit stringlit nested_id
delphipp_file ::=
pp_stmt_or_water
pp_stmt_or_water ::= pp_stmt pp_comment pp_any
pp_comment ::= cmbracketblock cmstarblock cmline
cmbracketblock ::= "{" bracketbody "}"
cmstarblock ::= "(*" starbody "*)"
bracketbody ::= pp_any
starbody ::= pp_any
cmline ::= "//" cmlinebody EOL
cmlinebody ::= pp_any
pp_any ::=
id codetoken
key
tokencodetoken ::= "(" ")" "." ";" ":" "," "[" "]" "+" "-" "*" "/" "^" "=" "@" ">" "<" "<>" ">=" "<=" ":=" "//" id anynumber charlit space
pp_stmt ::= pp_ifstmt pp_directivestmt
pp_directivestmt ::= "{$" space pp_directive "," bracketbody "}" "(*$" space pp_directive "," starbody "*)"
pp_directive ::= "DEFINE" space id "UNDEF" space id "INCLUDE" space filenamelit "I" space filenamelit "LINK" space filenamelit "L" space filenamelit "RESOURCE" space filenamelit space filenamelit "R" space filenamelit space filenamelit "HPPEMIT" space charlit "EXTERNALSYM" space id "NODEFINE" "MINENUMSIZE" "DENYPACKAGEUNIT" "WEAKPACKAGEUNIT" "IMAGEBASE" space anynumber "C" space id "MINENUMSIZE" space anynumber pp_minenumsize "ALIGN" space anynumber pp_align "M" space anynumber "," "MAXSTACKSIZE" space anynumber "MINSTACKSIZE" space anynumber "RESOURCERESERVE" space anynumber "NOINCLUDE" "WARN" "MESSAGE" "APPTYPE" "LIBPREFIX" space charlit "LIBSUFIX" space charlit "LIBVERSION" space charlit "DESCRIPTION" space charlit "D" space charlit "EXTENSION" space id "E" space id pp_switch space
pp_align ::= "A1" "A2" "A4" "A8"
pp_minenumsize ::= "Z1" "Z2" "Z4"
pp_switch ::=
id space
pp_switchoptpp_switchopt ::= "+" "-" "ON" "OFF"
pp_ifstmt ::=
pp_ifblock pp_elseifblock
pp_endifpp_ifblock ::=
pp_ifexpr pp_content
pp_content ::= pp_stmt_or_water
pp_elseifblock ::=
pp_elseifexpr pp_content
pp_ifexpr ::= "{$" space if_alt bracketbody "}" "(*$" space if_alt starbody "*)"
pp_elseifexpr ::= "{$" space else_alt space bracketbody "}" "(*$" space else_alt space starbody "*)"
pp_endif ::= "{$" space endif_alt bracketbody "}" "(*$" space endif_alt starbody "*)"
if_alt ::= "IF" space pp_boolexpr "IFDEF" space id "IFNDEF" space id "IFOPT" space pp_switch
else_alt ::= "ELSEIF" space pp_boolexpr "ELSE" space
endif_alt ::= "ENDIF" "IFEND"
pp_boolexpr ::= booleanlit boolfunc space"(" id ")" "NOT" space pp_boolexpr id pp_boolexpr "pp_boolopr" pp_boolexpr pp_litexpr "pp_compareopr" pp_litexpr "(" pp_boolexpr ")"
boolfunc ::= "DEFINED" "DECLARED" "OPTION"
booleanlit ::= "FALSE" "TRUE"
pp_litexpr ::= id charlit anynumber
pp_boolopr ::= "AND" "OR" "XOR"
pp_compareopr ::= ">" "<" "=" ">=" "<=" "<>"
anynumber ::= number hexnumber