DGrok Delphi Grammar
DGrok is my project to write a parser for the Delphi
language, and then to build interesting tools on top of
that parser. For more information on DGrok, see the
DGrok posts on my blog.
This page shows the Delphi grammar as I've
puzzled it out so far, and indicates how much of it
I've written a working parser for. Solid underline means
that rule is completely implemented in my parser; broken
underline means partly implemented; no underline means
something I haven't started yet.
Current status: Completed 98 rules of 98 = 100% complete.
Last updated Wed Oct 03 22:48:00 Central Daylight Time 2007.
— Joe White
Likely Targets (0)
These rules look like their dependencies are met,
and are likely targets to be implemented next. Numbers
in parentheses show how many places the rule is used.
(Completed) -> '+'
(Completed) -> '-'
(Completed) -> OR
(Completed) -> XOR
(Completed) -> ARRAY ['
[' (
Type ['
,'])+ '
]'] OF
Type
(Completed) -> ASM
(Completed) <assemblylanguage>
(Completed) END
(Completed) | '^'
(Completed) )*
(Completed) -> INHERITED
(Completed) END
(Completed) -> CLASS HELPER
(Completed) END
(Completed) -> CLASS
(Completed) [ABSTRACT | SEALED]
The remainder is optional, but only if the base class is specified and lookahead shows that the next token is a semicolon
(Completed) END
(Completed) ';'
(Completed) -> (CONST|RESOURCESTRING)
(Completed) -> [';'] ABSTRACT
(Completed) -> [';'] ASSEMBLER
(Completed) -> [';'] CDECL
(Completed) -> [';'] DYNAMIC
(Completed) -> [';'] EXPORT
(Completed) -> [';'] FAR
(Completed) -> [';'] FINAL
(Completed) -> [';'] FORWARD
(Completed) -> [';'] INLINE
(Completed) -> [';'] LOCAL
(Completed) -> [';'] NEAR
(Completed) -> [';'] OVERLOAD
(Completed) -> [';'] OVERRIDE
(Completed) -> [';'] PASCAL
(Completed) -> [';'] REGISTER
(Completed) -> [';'] REINTRODUCE
(Completed) -> [';'] SAFECALL
(Completed) -> [';'] STATIC
(Completed) -> [';'] STDCALL
(Completed) -> [';'] VARARGS
(Completed) -> [';'] VIRTUAL
(Completed) -> ON
(Completed) [';']
(Completed) -> <keyword>
(Completed) -> [[CLASS] VAR]
(Completed) -> FILE
(Completed) -> <identifier>
(Completed) -> <semikeyword>
(Completed) -> '&' <identifier>
(Completed) -> '&' <semikeyword>
(Completed) -> '&' <keyword>
(Completed) -> (
Ident ['
,'])+
(Completed) -> IMPLEMENTATION
(Completed) -> END
(Completed) -> INITIALIZATION
(Completed) [FINALIZATION
(Completed) END
(Completed) -> INTERFACE
(Completed) -> (INTERFACE | DISPINTERFACE)
(Completed) END
(Completed) -> LABEL (
LabelId ['
,'])+ '
;'
(Completed) -> <number>
(Completed) -> [CLASS]
(Completed) (PROCEDURE | FUNCTION | CONSTRUCTOR | DESTRUCTOR | OPERATOR)
(Completed) (
(Completed) )
(Completed) [';']
If the MethodHeading does not include 'external' or 'forward':
If the MethodHeading does include 'external' or 'forward':
(Completed) -> STRING
(Completed) -> '*'
(Completed) -> '/'
(Completed) -> DIV
(Completed) -> MOD
(Completed) -> AND
(Completed) -> SHL
(Completed) -> SHR
(Completed) -> ARRAY OF STRING
(Completed) -> ARRAY OF FILE
(Completed) -> ARRAY OF CONST
(Completed) END '.'
(Completed) -> PACKED
Type
(Completed) -> [VAR | CONST | OUT]
(Completed) -> STRING
(Completed) -> FILE
(Completed) -> <number>
(Completed) -> <stringliteral>
(Completed) -> NIL
(Completed) -> STRING
(Completed) -> FILE
(Completed) -> platform
(Completed) -> deprecated
(Completed) -> library
(Completed) -> experimental
(Completed) -> (PROCEDURE | FUNCTION)
(Completed) [OF OBJECT]
(Completed) -> [CLASS]
(Completed) PROPERTY
Ident
(Completed) ';'
(Completed) -> ';' DEFAULT
(Completed) -> NODEFAULT
(Completed) -> READONLY
(Completed) -> WRITEONLY
(Completed) END
(Completed) -> RECORD
(Completed) END
(Completed) -> '='
(Completed) -> '>'
(Completed) -> '<'
(Completed) -> '<='
(Completed) -> '>='
(Completed) -> '<>'
(Completed) -> IN
(Completed) -> IS
(Completed) -> AS
(Completed) -> SET OF
Type
(Completed) -> STRING
(Completed) -> TRY
(Completed) | EXCEPT (
(Completed) )
(Completed) END
Note: Delphi assumes that a Type starting with '(' is an enum, not an expression.
(Completed) -> '(' ')'
(Completed) -> Ident '
=' CLASS '
;'
(Completed) -> Ident '
=' DISPINTERFACE '
;'
(Completed) -> Ident '
=' INTERFACE '
;'
(Completed) -> NOT
(Completed) -> '+'
(Completed) -> '-'
(Completed) -> '@'
(Completed) -> INHERITED
(Completed) -> Ident IN <stringliteral>
(Completed) -> (USES | CONTAINS)
(Completed) ';'
(Completed) '('
(Completed) ')' [';']
(Completed) -> (VAR | THREADVAR) (
VarDecl)+
(Completed) -> STRICT PRIVATE
(Completed) -> STRICT PROTECTED
(Completed) -> PRIVATE
(Completed) -> PROTECTED
(Completed) -> PUBLIC
(Completed) -> PUBLISHED