Re: Syntax Diagrams

Subject: Re: Syntax Diagrams
From: Peter Gold <pgold -at- NETCOM -dot- COM>
Date: Wed, 20 Nov 1996 13:26:22 -0800

[snipped]

My friend who first brought syntax diagrams into my life prefers to stay
anonymous, but offers the following:

*** begin inclusion

The common method of syntax presentation with the brackets, braces,
color glossys with the circles and arrows, is called the Baccus Nour
(sic) format, most people call it BNR.

The syntax diagrams (SD) were developed at IBM. (The term "railroad
diagram" comes from the fact that they look like the schematics that
rail roads use to map out their lines.)

Each method has advantages. Basically, I found that SD diagrams worked
well for command languages, especially where the order of options wasn't
important. (A command language begins with an identifier, followed by
the options.) For example, "LIST FOR Free WHILE InStock" might also be
wrtten "LIST WHILE InStock FOR Free"

BNR worked better for function based languages (like C/C++). There the
order of the arguments is fixed, and there are usually few options. BNR
also has the advantage of "looking" more like the actual command that
gets typed in. " LIST [FOR <for-condition>] [WHILE <while-condition>]

Where BNR breaks down is when you have options within options: "one or
the other" situations. It becomes confusing to keep track of what is
available and where. SDs are good because they graphically spell out
which options go with which other arguments. For example:
"LIST {[FOR <for-condition>] | [WHILE <while-condition>]}"

To be most effective, SDs need arrows to indicate when something is
available.

LIST -+------------>+--+--+-> FOR <for-condition> -----+--+-->
+-> <scope> ->+ | +-> WHILE <while-condition> -+ |
+<---------------------------------+

But for complex commands, the diagrams can be HUGE and take up a whole
page.

****** end inclusion

Peter Gold


Previous by Author: Re: Documenting a Programming Language. WAS:Syntax Diagrams
Next by Author: Re: Correct Wording
Previous by Thread: Re: Syntax Diagrams
Next by Thread: My presentation


What this post helpful? Share it with friends and colleagues:


Sponsored Ads