Giving Grammars Written with ABNF Notation the Respect They Deserve

Michael Herman (Toronto/Calgary/Seattle)
Hyperonomy Business Blockchain Project / Parallelspace Corporation
February 2019

At one level, the Augmented BNF (ABNF) notation is simply a convenient textual approach for describing a grammar. In turn, a grammar is a description of the allowable linguistic constructs permitted in a particular language or any other syntactic construction. Examples of common and emerging grammars written using ABNF notation include:

More importantly, a grammar that conforms to the ABNF specification (RFC4234-4) is also an executable program.  That is, a grammar is the source code for program (written in the ABNF notation (aka ABNF programming language)) that recognizes and, optionally, processes a piece of text (string of tokens) that conforms to the grammar’s specification (expressed using ABNF notation).

Summary: The “ABNF Principles”

The “ABNF Principles” include:

  1. “ABNF” is a specification for a notation for describing a grammar.
  2. “ABNF notation” is the notation described in the ABNF specification for describing a grammar.
  3. A grammar is a description of the allowable linguistic constructs permitted in a particular language or any other syntactic construction.
  4. RFC4234-4 is a formal specification for ABNF notation.
  5. A grammar expressed using ABNF notation is intended to be executable.
  6. A grammar expressed using ABNF notation is the source code for a program that can be read, interpreted, compiled, and/or executed by a human, interpreter, compiler, or virtual machine, respectively, in a way that conforms to the ABNF formal specification.

Best Practices for Developing Grammars Written using ABNF Notation

  1. As in any software development project, it is of primary importance to understand the scope of the functionality, inputs, and outputs of the intended software (aka requirements).
  2. One of the best, commonly accepted ways to understand of the scope of the intended software to be developed is to work through the following series of artifacts:
    1. User stories, which in turn are decomposed into
    2. Use cases, and
    3. Requirements, and
    4. Specifications
  3. Use automation together with the use cases to create an automatable testing framework starting early in the project – automatically validating the the grammar against the test cases (derived from the use cases) on an ongoing basis.

NOTE: These artifacts can be developed iteratively using an agile or other type of development framework. It doesn’t require a waterfall approach.

 

 

1 Comment

Filed under Uncategorized

One response to “Giving Grammars Written with ABNF Notation the Respect They Deserve

  1. Agreed. We’d like to see grammars get more respect, and made more accessible. To that end, we’ve built a live-code syntax diagramming tool to help. Coincidetnally, the OData spec you mention recently became a great test case for it, because of its size.

    Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s