[fpc-pascal] machine readable grammar of object pascal?

denisgolovan denisgolovan at yandex.ru
Wed May 3 10:58:45 CEST 2017


> On 2017-05-03 00:53, Marc Santhoff wrote:
>>  Does such grammar exist?

Well, it depends on what you are trying to solve.
If you want to parse Pascal using FPC - that's one way. 
If you want to get some king of AST using any available [command-line] tools - that's another one.

Talking about latter - I would take LPEG (Lua+PEG) and create a parser myself. 
It comes quite simple and intuitive (contrary to LL,LR,LALR,...).
Most of Object Pascal is done right (minus sets/open arrays), so it can be parsed statically pretty easily.
See http://lua-users.org/wiki/LpegRecipes for inspiration.

-- 
Regards,
Denis Golovan



More information about the fpc-pascal mailing list