[Lazarus] Parser

Hans-Peter Diettrich DrDiettrich1 at aol.com
Thu Jul 1 00:54:21 CEST 2010


Florian Klämpfl schrieb:

>>>> There should exist a
>>>> method/procedure in the CPU specific code, that is called to create the
>>>> binary code for a procedure, but I could not yet locate it.
>>> psub.pas: tcgprocinfo.generate_code, it is generic.
>> I couldn't find out how the code generator is involved. Most methods are
>> non-virtual...
> 
> In the typical case the node tree codegenerator( ncg*.pas/n<cpu>*.pas)
> calls the methods in cgcpu.pas.

Since a mere parser is not a code generator, the 
tcgprocinfo.generate_code simply could become a virtual method, so that 
it could be overridden to e.g. export the tree. This change were almost 
not noticeable to ncg* and the other code generators, whose invocation 
by the base class implementation doesn't change at all.


> See above, the whole back end stuff is separated very well but diving
> into it is hell :)

The current Parser project will not affect the back-ends at all, only 
the parser procedures will be split into an syntactic and an semantic 
part. Once the semantic part can be exchanged, like currently a CPU can 
be exchanged, the parser-only implementation can create its own tree and 
other data structures, eliminating any need for special handling in the 
code generators. Similarly the currently broken preprocessor could 
output the preprocessed source code in its own semantic routines, 
independent from all code generation. Perhaps I can make the 
preprocessor work again, since its requirements (hooks, switches...) are 
almost the same as those of an mere parser.


BTW, it's not a good idea to have CPU specific code in the general 
compiler/parser units. E.g. PDecSub calls methods in the specialized 
TxxxParaManager classes, which are not found in the base class. I'll 
come back to this and other issues in a discussion in the FPC list. For 
now it's sufficient to discuss the possibilities from the user VP, 
that's why I started this thread in the Lazarus list.

DoDi





More information about the Lazarus mailing list