[fpc-devel] Need advice for refactoring

Hans-Peter Diettrich DrDiettrich1 at aol.com
Sat Jul 17 16:52:28 CEST 2010


Florian Klämpfl schrieb:

> My proposal is:
> - make a proof of concept for a part of the parser, e.g. ptype.pas, then
> we profile the old and the new compiler with valgrind with code which
> stresses this part.
> - then we decide if it's worth to continue

Thanks for pointing to ptype.pas, these routines made me rethink the 
current refactoring :-)

While my first idea was to steer everything by the syntax, I now found 
this approach not very useful. Details like finding the proper location 
of errors (too many arguments...) suggest to use background information 
in the first place, not after the syntax has been verified.

Consequently the new refactoring goal should result in "building 
blocks", like building the *internal* representation of e.g. a formal 
(or actual) parameter list. The generalization or abstraction then would 
be the use of (language specific) parser rules, to obtain the name and 
attributes of every parameter in that list.

The primary benefit of this refactoring is the possible encapsulation of 
the related data structures, resulting in more freedom in the 
maintenance of the encapsulated details. At the same time it will be 
possible to exchange the syntactical parser, for further languages or 
also for dedicated modes, in case this allows to simplify or speed up 
compilation. The latter part can be postponed, or inlined "naturally" 
into the OO rewrite.

This new approach also will be much more robust than the preceding one, 
because it does not change the semantical code, nor does it require to 
maintain copies of that code.


> I think also that a complete OOP approach should be used and: design it
> with multi threading in mind. Having a scanner/parser where multiple
> instances can be run at the same time would be a great benefit and I'am
> pretty sure that it will make it into fpc trunk.

With above redefinition we already agree about this (OOP) goal :-)

I'll retain a local backup of the parser_rewrite project, so that this 
project can be removed from the repository.


Then I'll start a new OO_rewrite project, and hope that it will be ready 
for a first profiling within a few days. Comments, anybody?

DoDi




More information about the fpc-devel mailing list