Subject: Grammar

From: "Clive D.W. Feather" <[email-masked]>
Date: Mon, 8 Jan 2007 15:00:10 +0000

I've taken the liberty of reviewing and rewriting the grammar. The
following grammar accepts exactly the same language as the original but, I
hope, is easier to understand and utilise.

I'll comment on the actual language in another message.

What I've changed:

* Renamed "comment-wsp" as "GAP", making it more obvious it's a syntactic
  item with no semantics.
* There's no need for * in front of uses of comment-wsp/GAP, since its own
  definition begins with *.
* Semicolon given a definition ("semi") to bring it into line with the
  other delimiters.
* At present the language alternates names and delimiters, so you can
  either put GAPs around delimiters or put them before every real token.
  However, the proposal with parentheses would break this paradigm.
  Therefore it's better to rearrange the grammar to allow GAP before any
  real token (and, for completeness, after the last statement).
* Added "name-list" to represent a comma-separated list of names.
* Rearranged the grammar to bring items at the same logical level together.
* "value" is identical to "name", so redefined it as such.
* Renamed "regular-identifier" as "identifier" (since that's what it's
  called in most languages).
* Renamed "identifer-chars" as "dquote-chars", since they're the characters
  in a quoted-name, not those in an identifier.
* Factored out "comment-nl", which didn't have any real use.
* Added definitions for all the undefined tokens (appendix B of RFC 4234
  is *NOT* part of the definition of ABNF).

======================================================================

   state-machine = 1*statement [GAP]

   statement = (declaration / transition / assignment) semi

   declaration = name-list colon value
   ; ALTERNATIVE: indicate the possible values in the grammar:
   ; declaration = name-list colon type
   ; type = "state" / "message" / "action"

   assignment = name equal value

   transition = current-states colon
                messages arrow next-state
                [colon action]

   ; ALTERNATIVE : some people prefer to put the message first:
   ;transition = message colon
   ;             current-state arrow next-state
   ;             [colon action]

   ; ALTERNATIVE: some people prefer to see the current-state and
   ; the message grouped together:
   ;transition = left-paren current-state comma message right-paren
   ;             arrow next-state
   ;             [colon action]

   ; ALTERNATIVE: allow some grouping, for instance:
   ;   Signal1:
   ;     IDLE -> BUSY:
   ;       connectSubscriber;
   ;     CONNECTING -> DISCONNECTING:
   ;       disconnectSubscriber
   ; # Henk-Jan van Tuyl <[email-masked]>

   ; ALTERNATIVE: allow more than one action, comma-separated
   ;  Marc Petit-Huguenin <[email-masked]>

   current-states = name-list
   messages = name-list
   next-state = name
   action = name

   value = name

; Identifiers

   name-list = name *(comma name)

   name = GAP (quoted-name / identifier)

   quoted-name = DQUOTE 1*(dquote-chars) DQUOTE

   ; TODO: this grammar allows identifiers like foo----bar
   ; (several dashes). Do we really want it?
   identifier = ALPHA / (ALPHA *(ALNUM / "-") ALNUM)

; Syntactic items

   dquote-chars = ALPHA / DIGIT /
                      "-" / "_" / "'" / "," / ";" / SP
                     ; All letters and digits and
                     ; some (a bit arbitrary) chars

   semi  = GAP ";"
   colon = GAP ":"
   comma = GAP ","
   equal = GAP "="
   arrow = GAP "->"

; Gaps and comments
; All GAPs are ignored and don't affect the meaning of the state-machine

   GAP = *gap-item

   gap-item = WSP / CRLF / comment

   comment =  "#" *(WSP / VCHAR) CRLF

; items taken from RFC 4234 appendix B

   ALNUM = ALPHA / DIGIT
   ALPHA = %x41-5A / %x61-7A
   CRLF = %x0D.0A
   DIGIT = %x30-39
   DQUOTE = %x22
   HTAB = %x09
   SP = %x20
   VCHAR = %x21-7E
   WSP = SP / HTAB

-- 
Clive D.W. Feather  | Work:  <[email-masked]>   | Tel:    +44 20 8495 6138
Internet Expert     | Home:  <[email-masked]>  | Fax:    +44 870 051 9937
Demon Internet      | WWW: http://www.davros.org | Mobile: +44 7973 377646
THUS plc            |                            |

_______________________________________________
Cosmogol mailing list
[email-masked]
https://www1.ietf.org/mailman/listinfo/cosmogol

---

From: Stephane Bortzmeyer <[email-masked]>
Date: Mon, 8 Jan 2007 22:04:05 +0100

On Mon, Jan 08, 2007 at 03:00:10PM +0000,
 Clive D.W. Feather <[email-masked]> wrote 
 a message of 132 lines which said:

> I've taken the liberty of reviewing and rewriting the grammar. 

First, many thanks for the huge practical work. I've not studied it in
depth, yet, but I invite people to read it and express opinions about
what we should integrate in -02.

Second, a few details (more substantive comments will follow):

> * Renamed "comment-wsp" as "GAP", making it more obvious it's a
> syntactic item with no semantics.

XXX-wsp is already used as a production name in RFCs. See RFC 4234
which have set the example.

>   is *NOT* part of the definition of ABNF).

Hmmm, I thought the purpose of "core" (appendix B) was precisely to
avoid redefinition. So, it seems to me there is no need to add these
definitions. (See option -t of abnfgen.)

---

From: "Clive D.W. Feather" <[email-masked]>
Date: Mon, 8 Jan 2007 23:57:23 +0000

> which have set the example.

But at least they called it c-wsp, which is less obtrusive when you come to
read the syntax. If you wanted to use that, I wouldn't object.

> avoid redefinition.

In which case you need to explicitly call it in.

| Appendix B supplies rule definitions [...] It is provided as a
| convenience and is otherwise separate from the meta language defined
| in the body of this document, and separate from its formal status.

I agree terms used in appendix B shouldn't be given different meanings, but
in RFC 3977 (blush) we included a definition of all those we used.