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

Jamie McCracken jamie-junk at blueyonder.co.uk
Sat Jun 4 11:00:49 CEST 2005


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!).

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.

I can also totally eliminate circular refs in the multi pass phase (it 
will require three passes if there are circular refs, otherwise one or 
two passes will be sufficient). The advantage for the developer here is 
that only one uses clause ever needs to be used.

Looking at the tokens.pas file in the compiler, every token in the 
parser is specified against which dialect implements it (via the mode 
switch) so it shouldn't be too difficult to remove any redundant syntax 
where its not needed. (I emphasize removing not adding syntax here!)

> 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.

For replacing Begin..End blocks with indents in my new dialect I planned 
to use the compiler's internal preprocessor in the compiler to put back 
the begin/end blocks without affecting the line numbers. I can do 
likewise for syntactic sugar.

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.

Thanks

jamie.




More information about the fpc-devel mailing list