[fpc-pascal] Pascal Lexical Diagrams

Jürgen Hestermann juergen.hestermann at gmx.de
Sat Jan 30 13:26:21 CET 2016


Am 2016-01-30 um 10:45 schrieb Anthony Walter:
 > I've been working on writing Javascript to generate lexical language diagrams for the getlazarus.org learning center portal.
 > With my script I'm able to render these diagrams which will be appear under the Free Pascal language Lexical topic:
 > http://cache.getlazarus.org/images/lexical-diagrams.png
 > Hopefully they are clear enough in their schematic design such they're understandable. I'll be adding code examples and brief summaries to each diagram which will likely be of aide.

The look of the diagrams is very good.

Some things that I think can be improved:

1.) Direction of lines:
The lines should have arrows to denote the direction in which a diagram has to be followed. This would allow recursive definitions.
Example: http://i.stack.imgur.com/SOq3x.gif
It would also avoid the somewhat irritating use of words like [repeat] and [open symbol] which are only needed because of the missing arrows.

2.) \n
I think \n is not used in Pascal (it's more a C convention). Instead it should be named "line ending" or something like that. Also, especially new users may not know what \n means (unless they come from C).

3.) String literal:
Why does (char literal) appear twice? There can be any number of (char literals) so I think it would be clearer to have a simple recursive loop:

   />-'[any character other than "line ending"]'->-|
->->-------------(char literal)----------------->-|->-
   \----------------------<------------------------/

4.) Comment:
There should only be simply 3 kinds of comments:
    /->-(//)----[line ending]->-\
->--->-({)---------------(})->-|->-
    \->-((*)--------------(*))--/

5.) Identifier:
Same here, instead of the [repeat] word arrows should be used.





More information about the fpc-pascal mailing list