[fpc-pascal] Access to compiler's internal data structures

Bernd prof7bit at gmail.com
Sat Sep 1 10:54:18 CEST 2012


2012/8/31 Kenneth Cochran <kenneth.cochran at gmail.com>:

> I'm finding myself in need of a parser for object pascal. I'm wondering if
> fpc exposes any of the output (syntax trees, graphs, etc) from the parser
> that could be consumed by an external tool?

Depending on what exactly you need and how difficult it is to get a
syntax tree from the compiler itself there exist at least two more
parsers that *might* be useful for you: one of them is in the
CodeTools package in Lazarus and is used for autocomplete,
refactoring, etc and another totally separate parser is in the Jedi
code formating package (also part of Lazarus) that is used for
re-formatting the code of a single unit.

These parsers were written with different goals in mind and for
different purposes, so they work slightly different and provide
different output, for example the jedi parser will only parse one unit
(and is not very closely connected with the IDE and can probably
easily be ripped out of it and be used in a separate project) while
the codetools parsers are able to follow used units, include files,
respect currently active defines, etc. but are deeply integrated into
the IDE and probably also depending on many parts of he IDE.

If the project you have in mind would be something that helps coding
or understanding and analyzing existing code it might probably be very
nice to have it available as a part of the Lazarus IDE (as an
installable package) and let it extend the CodeTools parsers.



More information about the fpc-pascal mailing list