Modern Pascal Dialect [was Re: [fpc-devel] Re: [fpc-l] typediscussion]

Hans-Peter Diettrich DrDiettrich at compuserve.de
Sun Jun 5 11:19:58 CEST 2005


Jamie McCracken wrote:
> 
> Hans-Peter Diettrich wrote:
> 
> > You obviously missed that a compiler does not only consist of scanner
> > and parser, but that optimizers and code generators also have to be
> > implemented. For multiple target platforms and CPU's...
> 
> The new dialect simply makes the syntax less annoying and verbose - it
> wont alter functionality as such so altering those shouldn't be on the
> agenda (I hope!).

Consider the communication between the parser and the code generator.
I'm not sure about FPC, but usually a parse tree is generated first,
then the remaining code works with that parse tree. Herefore your parser
will have to create a tree structure that is compatible with what the
compiler expects.


> The new dialect simply requires a multi pass parser. It shouldn't be too
> hard to adapt the existing one for this purpose. Of course the compiler
> will only use this if the source file tells it to use Rad Pascal dialect
> so it wont affect or harm compiler performance of other dialects.

Hmm, I wonder how a multi pass parser fits together with RAD ;-)

OTOH, are you sure that more passes really are required?
Many languages require that the parser must know about the declaration
(or type) of every identifier. This is not a requirement for Pascal!

The requirement for forward declarations can be replaced by an
appropriate symbol table implementation, which allows to add the
declaration to every identifier later. The implementation only must
assure that *subsequent* declarations or definitions are added to the
correct *previously* entered identifier.


> > The safe approach is to write an preprocessor, that can translate your
> > dialect into any implemented language, so that the compiler code must
> > not be touched. Then you'll find out that your dialect needs code
> > completion and other features, that have to be implemented as well,
> > apart from the compiler. These are fine exercises before you start
> > bothering with the compiler code.
> 
> I had thought of that but thats problematic for debugging. IE the
> compiler returns line numbers for errors and they will not match if I
> use an external preprocessor.

AFAIR a solution was already posted?

> If you or anybody else has advise on how best to implement it then
> please let me know - I apreciate anything that will help me here.

See my above suggestions ;-)

DoDi






More information about the fpc-devel mailing list