Appendix A - Syntax definition

Below is the syntax definition of the ESL language in Extended Backus-Naur Form (EBNF). The specification should be read as follows:

Notation

Should be read as

“abc”

Literal text “abc”

\n

Continue at the next line

DEF

Terminal DEF

ghi

Expansion of rule ghi

a b

a followed by b

a | b

Either a or b

a ( b | c)

a followed by either a or b

[a]

a or nothing

{a}

Sequence of zero or more times a

{a}+

Sequence of one or more times a

x ::= b c

x is defined as b followed by c

/* note

Comment or additional constraint

An ESL specification is described by rule esl-specification.

esl-specification ::=
  { type-definition
  | verb-definition
  | relation-definition
  | world-section /* Exactly one */
  | component-definition }+

/* -------------------------------- */
/* Types */

type-definition ::=
  "define" "type" \n
  { new-singular-type \n
  | new-bundle-type \n
  }+

new-singular-type ::= (
  TYPE-NAME [ enumeration-specification | unit-specification | range-specification ]
|
  TYPE-NAME "is" ( "a" | "an" ) TYPE-NAME [
     unit-specification | range-specification
   ]
)

new-bundle-type ::=
  TYPE-NAME "is" "a" "bundle" "of" \n
  { "*" bundle-field-specification }+

bundle-field-specification ::= (
  FIELD-NAME "is" ( "a" | "an" ) TYPE-NAME
)

unit-specification ::=
  "with" ( "unit" | "units" ) UNIT-NAME { "," UNIT-NAME }

enumeration-specification ::=
  "is" "an" "enumeration" "of" VALUE [ unit ] { "," VALUE [ unit ]}

range-specification ::=
  ( interval-specification | constant-specification )

interval-specification ::=
  "of" interval { "or" interval }

interval ::=
  ( open-interval | closed-interval )

open-interval ::=
  ( lower-bound | upper-bound )

closed-interval ::=
  lower-bound "and" upper-bound

lower-bound ::=
  "at" "least" VALUE [ unit ]

upper-bound ::=
  "at" "most" VALUE [ unit ]

constant-specification ::=
  "equal" "to" VALUE [ unit ]

/* -------------------------------- */
/* Verbs and relations */

verb-definition ::=
    "define" "verb" \n
  { VERB PREPOSITION \n }+

relation-definition ::=
  "define" "relation" \n
  { RELATION-DEF-NAME \n
    { ( "requiring" | "returning" | "relating" ) "parameter"  \n
      { "*" ["one" "or" "more"] PARAMETER-NAME "is" ("a" | "an") TYPE-NAME \n }+
    }+ /* At most one requiring, returning and relating. */
  }+

/* -------------------------------- */
/* World and component */

world-section ::=
    "world" \n
  ( "empty" | { variable-section
              | group-section
              | component-section
              | need-section
              | goal-section
              | behavior-section
              | design-section
              | comment-section }+ )

component-definition ::=
    "define" "component" COMPONENT-KIND \n
  ( "empty" | { parameter-section
              | variable-section
              | group-section
              | transform-section
              | component-section
              | need-section
              | goal-section
              | behavior-section
              | design-section
              | comment-section }+ )

component-section ::=
    "component" \n
  { COMPONENT-NAME "is"
  ( "a" | "an" ) COMPONENT-KIND
  (  \n | arguments  )  }+

/* -------------------------------- */
/* Parameter and variable */

parameter-section ::=
    "parameter" \n
  { PARAMETER-NAME { "," PARAMETER-NAME }
    "is" ( "a" | "an" ) TYPE-NAME [ "property" ] \n
  }+

variable-section ::=
    "variable" \n
  { VARIABLE-NAME { "," VARIABLE-NAME }
    "is" ( "a" | "an" ) TYPE-NAME  \n
  }+

group-section ::=
  "variable-group" \n
  { group-definition }+

group-definition ::=
  GROUP-NAME "is" "a" "group" "of" \n
    argument-list

/* -------------------------------- */
/* Argument */

arguments ::=
    "with" "arguments" \n
    argument-list

argument-list ::=
  { "*" argument-name
    { "," argument-name } \n
  }+

argument-references ::=
    argument-name
  { and-connector argument-name } \n

and-connector ::=
    "and"
  | ","
  | "," "and"

argument-name ::=
    PARAMETER-NAME
  | VARIABLE-NAME

/* -------------------------------- */
/* Need */

need-section ::=
    "need" \n
  { NEED-NAME ":" need-literal \n }+

need-literal ::=
    subject-name { WORD }+

subject-name ::=
    argument-name
  | COMPONENT-NAME
  | GOAL-NAME
  | TRANSFORMATION-NAME
  | DESIGN-NAME
  | BEHAVIOR-NAME

/* -------------------------------- */
/* Goal */

goal-section ::=
    goal-type \n
  { GOAL-NAME ":" goal-literal }+

goal-type ::=
    "goal-requirement"
  | "goal-constraint"

goal-literal ::=
    COMPONENT-NAME
  ( "does"           /* constraint */
  | auxiliary-verb ) /* requirement */
    VERB argument-references PREPOSITION
    COMPONENT-NAME
  ( \n | subclauses )

/* -------------------------------- */
/* Behavior */

behavior-section ::=
  behavior-type \n
  { BEHAVIOR-NAME ":" \n
    behavior-clause
  }+

behavior-type ::=
  "behavior-requirement" | "behavior-constraint"

behavior-clause ::=
  {
    "case" CASE-NAME ":" \n
    ( regular-case-clause
    | fall-back-case-clause
    )
  }+ /* At most one fall-back-case-clause per behavior-clause. */

regular-case-clause ::=
  when-clause
  then-clause

when-clause ::=
  "when" \n
    { "*" CASE-CONDITION-NAME ":" comparison-rule-line \n }+ /* Only 'is' as auxiliary verb. */

then-clause ::=
  "then" \n
    { "*" CASE-RULE-NAME ":" comparison \n }+

fall-back-case-clause ::=
  "when" "no" "other" "case" "applies" \n
  then-clause


/* -------------------------------- */
/* Transform */

transform-section ::=
    transformation-type \n
  { TRANSFORMATION-NAME ":"
    transform-literal \n }+

transformation-type ::=
    "transformation-requirement"
  | "transformation-constraint"

transformation-literal ::=
  ( "does"           /* constraint */
  | auxiliary-verb ) /* requirement */
    VERB argument-references PREPOSITION
    argument-references
  ( \n | subclauses )

/* -------------------------------- */
/* Design-rules */

design-section ::=
    design-rule-type \n
  { DESIGN-RULE-NAME ":"
    design-rule-line }+

design-rule-type ::=
    "design-requirement"
  | "design-constraint"

design-rule-line ::=
  comparison-rule-line
  ( \n | subclauses )

/* -------------------------------- */
/* Subclauses */

subclauses ::=
  "with" "subclauses" \n
  { "*" SUBCLAUSE-NAME ":"
    comparison-rule-line \n
  }+

/* -------------------------------- */
/* Comparison */

comparison-rule-line ::=
  comparison
  { "or" comparison }

comparison ::=
  argument-name
  ( constraint-rule-literal | requirement-rule-literal )

constraint-rule-literal ::=
  "is" compare-op bound

requirement-rule-literal ::=
  auxiliary-verb "be"
  ( compare-op bound | objective )

compare-op ::=
    "smaller" "than"
  | "greater" "than"
  | "not" "equal" "to"
  | "equal" "to"
  | "at" "least"
  | "at" "most"
  | "approximately" /* Only in a requirement-rule-literal */

bound ::=
    argument-name
  | VALUE [ unit ]
  | "t.b.d." [ unit ]

unit ::=
    UNIT-NAME
  | "[" UNIT-NAME "]"

objective ::=
    "maximized"
  | "minimized"

/* -------------------------------- */
/* Relations */

relation-section ::=
  "relation" \n
  { RELATION-NAME ":" RELATION-DEF-NAME \n
    { ( "requiring" | "returning" | "relating" ) "argument"  \n
      { "*" argument-name \n }+
    }+ /* At most one requiring, returning and relating. */
  }+

/* -------------------------------- */
/* Comments */

comment-section ::=
    "comment"
  { target-name "#<" { WORD } \n }+

target-name ::=
    argument-name
  | COMPONENT-NAME
  | NEED-NAME
  | GOAL-NAME
  | TRANSFORMATION-NAME
  | RELATION-NAME

/* -------------------------------- */
/* Requirement verbs */

auxiliary-verb ::=
    "shall"
  | "must"
  | "should"
  | "could"
  | "won't"