[fpc-devel] Re: [fpc-l] type discussion

Hans-Peter Diettrich DrDiettrich at compuserve.de
Fri Jun 3 08:51:35 CEST 2005

Jamie McCracken wrote:

> okay but my idea was to have a new dialect (i'll call it RAD-Pascal) as
> FPC supports multiple dialects it can slip in without affecting existing
> code so if people dont like it they dont have to use it. Im quite happy

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

> to write it myself but I will need help on where to look and what to
> modify in the compiler as im not familliar with the compiler source (I
> cant even find the grammar for the language so I take it you dont use a
> table driven or auto generated parser like yacc)

You'll find an (incomplete) grammar, with railroad diagrams, in the
syntax description. In the last version the code resides in the compiler
directory, you may have to download the compiler and library sources
separately. Another (simpler) parser can be found in
fcl\passrc\pparser.pp, but it is not so close to the current FPC parser.

And yes, the parser is a handcrafted top-down (recursive descent)
parser, easier to maintain, extend, and debug, than bottom-up parsers.
Of course you can use CoCo/R for your parser, if you want an parser
generator, or lex/yacc if you like, for which also ports with Pascal
output are available (dyacclex, tply).

BTW, for code completion and other RAD features, a top-down parser is
almost the only choice, because it allows to parse specific parts of the
code (statements...). In a bottom-up parser you have little chances to
find equivalent initial and final states for the parser automaton.

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.

Hmm, why don't you start with the Lazarus sources? There you'll find
everything related to entering and editing source code, code explorer
and other RAD features...

If you found the source code, please open another thread for further
discussion. Perhaps there exists another mailing list for Lazarus?


More information about the fpc-devel mailing list