Grammar

"Clive D.W. Feather" <clive@demon.net> Mon, 08 January 2007 15:00 UTC

Received: from [127.0.0.1] (helo=stiedprmman1.va.neustar.com) by megatron.ietf.org with esmtp (Exim 4.43) id 1H3vyv-0004PZ-DK; Mon, 08 Jan 2007 10:00:13 -0500
Received: from [10.91.34.44] (helo=ietf-mx.ietf.org) by megatron.ietf.org with esmtp (Exim 4.43) id 1H3vyu-0004Oe-Qk for cosmogol@ietf.org; Mon, 08 Jan 2007 10:00:12 -0500
Received: from anchor-internal-1.mail.demon.net ([195.173.56.100]) by ietf-mx.ietf.org with esmtp (Exim 4.43) id 1H3vyt-0007OH-CV for cosmogol@ietf.org; Mon, 08 Jan 2007 10:00:12 -0500
Received: from finch-staff-1.server.demon.net (finch-staff-1.server.demon.net [193.195.224.1]) by anchor-internal-1.mail.demon.net with ESMTP� id l08F0Afa006032; Mon, 8 Jan 2007 15:00:10 GMT
Received: from clive by finch-staff-1.server.demon.net with local (Exim 3.36 #1) id 1H3vys-000FBj-00 for cosmogol@ietf.org; Mon, 08 Jan 2007 15:00:10 +0000
Date: Mon, 8 Jan 2007 15:00:10 +0000
From: "Clive D.W. Feather" <clive@demon.net>
To: cosmogol@ietf.org
Message-ID: <20070108150010.GR12419@finch-staff-1.thus.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.5.3i
X-Spam-Score: 0.0 (/)
X-Scan-Signature: b22590c27682ace61775ee7b453b40d3
Subject: Grammar
X-BeenThere: cosmogol@ietf.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: DIscussion on state machine specification in IETF protocols <cosmogol.ietf.org>
List-Unsubscribe: <https://www1.ietf.org/mailman/listinfo/cosmogol>, <mailto:cosmogol-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www1.ietf.org/pipermail/cosmogol>
List-Post: <mailto:cosmogol@ietf.org>
List-Help: <mailto:cosmogol-request@ietf.org?subject=help>
List-Subscribe: <https://www1.ietf.org/mailman/listinfo/cosmogol>, <mailto:cosmogol-request@ietf.org?subject=subscribe>
Errors-To: cosmogol-bounces@ietf.org

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 <hjgtuyl@chello.nl>

   ; ALTERNATIVE: allow more than one action, comma-separated
   ;  Marc Petit-Huguenin <marc@8x8.com>

   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:  <clive@demon.net>   | Tel:    +44 20 8495 6138
Internet Expert     | Home:  <clive@davros.org>  | Fax:    +44 870 051 9937
Demon Internet      | WWW: http://www.davros.org | Mobile: +44 7973 377646
THUS plc            |                            |

_______________________________________________
Cosmogol mailing list
Cosmogol@ietf.org
https://www1.ietf.org/mailman/listinfo/cosmogol