Browsable Borland Delphi preprocessor Grammar

CC-BY

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

Summary

Syntax

ident ::=
	id
	key
namespace ::=
	id "."
nested_id ::=
	SPOFF namespace* ident SPON
filenamelit ::=
	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
	token
codetoken ::=
	"("
	")"
	"."
	";"
	":"
	","
	"["
	"]"
	"+"
	"-"
	"*"
	"/"
	"^"
	"="
	"@"
	">"
	"<"
	"<>"
	">="
	"<="
	":="
	"//"
	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_switchopt
pp_switchopt ::=
	"+"
	"-"
	"ON"
	"OFF"
pp_ifstmt ::=
	pp_ifblock pp_elseifblock* pp_endif
pp_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

GrammarLabMaintained by Dr. Vadim Zaytsev a.k.a. @grammarware. Last updated in September 2015. []