Prokee Syntax Notation

From prokee
Jump to navigation Jump to search

The Prokee Syntax Notation is a notation for syntax rules used by some prokee modules.

Characteristics:

  • Terminal symbols are written without quotation marks.
  • There is no concatenation operator. Successive symbols are written one after the other (without a comma or space).
  • There is no termination symbol, like ';' (or. '.'). The syntax rules are usually specified individually as separate string literals, which means that no termination symbol is necessary.
  • For optional repetitions, "{ }" (as in EBNF) is omitted. Instead, three dots "..." are used to indicate optional continuation. Since repetition is always optional, the three points are enclosed in square brackets (see examples below).
  • Any unicode characters can be used as terminal symbols. (Preferred encoding is UTF-8.)
  • Spaces are not treated differently than other terminal symbols.
  • If non-terminal symbols are to be used as terminal symbols, then a backslash can be prefixed to this symbol.
  • As in EBNF, grouping is done with "( )" and optional parts are written within brackets "[ ]". And '|' is used for alternatives.
  • Within angle brackets "<>", additional syntax specifications can be specified depending on the application.

The following table shows a comparison between EBNF and Prokee Syntax Notation.

EBNF Prokee Notation Remarks
Terminal symbols 'a' a No single or double quotes
Termination symbol 'a'; a No termination symbol
Concatenation 'a', 'b', 'c' abc No spaces, no concatenation operator
Alternatives with '|' 'a', 'b' | 'c' ab|c
Grouping 'a', ( 'b' | 'c' ) a(b|c)
Optional parts 'a', [ 'b' ] , 'c' a[b]c
Optional repetition, example 1 'a', { 'b' }, 'c' a[b[...]]c Optional repetition of the element left of [...]
Optional repetition, example 2 'a', 'b', { 'b' }, 'c' ab[...]c
Optional repetition, example 3 'a', 'b', { 'a', 'b' }, 'c' (ab)[...]c
Optional repetition (with separator) 'x', { ',', 'x' } x[,...] equal to x[(,x)[...]]
Optional repetition (with separator) 'x', { '--', 'x' } x[--...] equal to x[(--x)[...]]
Optional repetition of optional element { 'x' } [x]... equal to [x[...]]