472,351 Members | 1,637 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,351 software developers and data experts.

Railroad track syntax diagrams

Back in the mid-90's, Kees Blom generated a set of railroad syntax diagrams
for Python
(http://python.project.cwi.nl/search/...4q3/0286.html).
This pre-dates any Python awareness on my part, but I'm sure this would have
been version 1.3 or something.

For those who are not familiar with railroad syntax diagrams, they show a
grammar's syntax using arrows and blocks, instead of BNF - here's an excerpt
from the Python grammar, plus "ASCII-art" diagrams - must be viewed in
non-prop font to be appreciated:

suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT

----+--simple_stmt --------------------------------->\
| |
\--NEWLINE --INDENT --+--stmt --+--DEDENT --+-->
/ |
\----<-------/

if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite]
--'if' -test --':' --suite -->+
|
------------<-------------------+
/
+
| ------------<------------------------
|/ \
+ |
| |
+-'elif' -test -':' --suite -->/
|
|
+-'else' -':' --suite -->
| \
\---------------->--------------+------->
I was recently contacted by a volunteer in Banda Aceh teaching tsunami
refugees how to program in Python (new job skills and all that), and he
asked if there were any updated versions of these diagrams, or if it would
be difficult to generate them anew. It seems that railroad diagrams are
nice and unambiguous for his students to use, in the face of verbal language
barriers.

I have written a pyparsing parser that reads the grammar file that ships
with Python - the parser is included in the latest release of pyparsing, and
also online at the pyparsing.wikispaces.com - but I have no graph-generating
tools to go the next step: generation of the railroad diagrams (in something
more legible/appealing than ASCII-art!).

Anyone interested in helping complete this last step?

Thanks,
-- Paul
Aug 1 '06 #1
6 4622
Paul McGuire <pt***@austin.rr._bogus_.comwrote:
For those who are not familiar with railroad syntax diagrams, they
show a grammar's syntax using arrows and blocks, instead of BNF
I've always liked railroad diagrams. Oracle used to use them (maybe
they still do?) in their SQL reference manuals. I find them much
easier to understand than BNF.
Aug 1 '06 #2
On 2006-08-01, Roy Smith <ro*@panix.comwrote:
Paul McGuire <pt***@austin.rr._bogus_.comwrote:
>For those who are not familiar with railroad syntax diagrams, they
show a grammar's syntax using arrows and blocks, instead of BNF

I've always liked railroad diagrams.
Me too. The Pascal text we used 25 years ago had a section in
the back with railroad diagrams, and a section with BNF. I
never ran into anybody who preferred the BNF.

--
Grant Edwards grante Yow! I always liked FLAG
at DAY!!
visi.com
Aug 1 '06 #3

Paul McGuire wrote:
Back in the mid-90's, Kees Blom generated a set of railroad syntax diagrams
for Python
(http://python.project.cwi.nl/search/...4q3/0286.html).
This pre-dates any Python awareness on my part, but I'm sure this would have
been version 1.3 or something.

For those who are not familiar with railroad syntax diagrams, they show a
grammar's syntax using arrows and blocks, instead of BNF - here's an excerpt
from the Python grammar, plus "ASCII-art" diagrams - must be viewed in
non-prop font to be appreciated:

suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT

----+--simple_stmt --------------------------------->\
| |
\--NEWLINE --INDENT --+--stmt --+--DEDENT --+-->
/ |
\----<-------/

if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite]
--'if' -test --':' --suite -->+
|
------------<-------------------+
/
+
| ------------<------------------------
|/ \
+ |
| |
+-'elif' -test -':' --suite -->/
|
|
+-'else' -':' --suite -->
| \
\---------------->--------------+------->
I was recently contacted by a volunteer in Banda Aceh teaching tsunami
refugees how to program in Python (new job skills and all that), and he
asked if there were any updated versions of these diagrams, or if it would
be difficult to generate them anew. It seems that railroad diagrams are
nice and unambiguous for his students to use, in the face of verbal language
barriers.

I have written a pyparsing parser that reads the grammar file that ships
with Python - the parser is included in the latest release of pyparsing, and
also online at the pyparsing.wikispaces.com - but I have no graph-generating
tools to go the next step: generation of the railroad diagrams (in something
more legible/appealing than ASCII-art!).

Anyone interested in helping complete this last step?

Thanks,
-- Paul
I googlled and got these:
http://www.informatik.uni-freiburg.d...skell/ebnf2ps/
http://www.antlr.org/share/1107033888258/SDG2-1.5.zip

- Paddy.

Aug 1 '06 #4

Paddy wrote:
Paul McGuire wrote:
Back in the mid-90's, Kees Blom generated a set of railroad syntax diagrams
for Python
(http://python.project.cwi.nl/search/...4q3/0286.html).
This pre-dates any Python awareness on my part, but I'm sure this would have
been version 1.3 or something.

For those who are not familiar with railroad syntax diagrams, they show a
grammar's syntax using arrows and blocks, instead of BNF - here's an excerpt
from the Python grammar, plus "ASCII-art" diagrams - must be viewed in
non-prop font to be appreciated:

suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT

----+--simple_stmt --------------------------------->\
| |
\--NEWLINE --INDENT --+--stmt --+--DEDENT --+-->
/ |
\----<-------/

if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite]
--'if' -test --':' --suite -->+
|
------------<-------------------+
/
+
| ------------<------------------------
|/ \
+ |
| |
+-'elif' -test -':' --suite -->/
|
|
+-'else' -':' --suite -->
| \
\---------------->--------------+------->
I was recently contacted by a volunteer in Banda Aceh teaching tsunami
refugees how to program in Python (new job skills and all that), and he
asked if there were any updated versions of these diagrams, or if it would
be difficult to generate them anew. It seems that railroad diagrams are
nice and unambiguous for his students to use, in the face of verbal language
barriers.

I have written a pyparsing parser that reads the grammar file that ships
with Python - the parser is included in the latest release of pyparsing, and
also online at the pyparsing.wikispaces.com - but I have no graph-generating
tools to go the next step: generation of the railroad diagrams (in something
more legible/appealing than ASCII-art!).

Anyone interested in helping complete this last step?

Thanks,
-- Paul
I googlled and got these:
http://www.informatik.uni-freiburg.d...skell/ebnf2ps/
http://www.antlr.org/share/1107033888258/SDG2-1.5.zip

- Paddy.
And this suite includes a digram generator:

http://www.research.philips.com/tech...ant/index.html

- Pad.

Aug 1 '06 #5
Paddy wrote:
I googlled and got these:
http://www.informatik.uni-freiburg.d...skell/ebnf2ps/
http://www.antlr.org/share/1107033888258/SDG2-1.5.zip
There is another beast, also called ebnf2ps, but in elisp
(runs inside the editor).

It requires no additional software (i.e. no ghc) and is simpler
to use (no questions about inexistent .afm files etc.)

Ralf
Aug 2 '06 #6
Paul McGuire:
generation of the railroad diagrams (in something
more legible/appealing than ASCII-art!).
That ASCII-art looks easy enough to read. It may be bad when the graph
becomes very big.

Bye,
bearophile

Aug 3 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: sams | last post by:
Is there a flow draw tool/API in Java to map out a simple application flow? Tks Sam
2
by: Irlan agous | last post by:
Hello all, I suppose many people use unl for modeling. Does anybody know a free good uml tool to make sequence diagrams, from the use cases? I...
14
by: Uwe Mayer | last post by:
Hi, I know the python community is not very receptive towards extending the python syntax. Nevertheless I'd like to make a suggestion and hear...
6
by: Clay Beatty | last post by:
When you create database diagrams in Enterprise Manager, the details for constructing those diagrams is saved into the dtproperties table. This...
4
by: Bob Stearns | last post by:
The statement: merge into nullid.animals_et_in t1 using is3.animals t2 on t1.sire_assoc=t2.assoc and t1.sire_prefix=t2.prefix and...
4
by: PIEBALD | last post by:
I'm trying to find a general definition/specification for railroad diagrams. All I find online are explanations by authors who explain what _their_...
0
by: craig dunn | last post by:
I've used the code from the post for a while now... but recently upgraded to SQL Server 2005. I've written a new script for SQL Server 2005,...
4
by: Ole Nielsby | last post by:
In the old ages when I was taught Pascal, the manual had nice syntax diagrams. Each grammatical structure was shown as round boxes connected by...
3
by: BD | last post by:
Hi, folks. Sorry about this - I have been R'ing all TFM's I can find, but am just getting more frustrated. Background: db2 UDB 8.1 on...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.