How to use browsable C# grammar


Non-terminals

Everything in a grammar with a link on it is a non-terminal symbol:

a:
    b

b:
    a

Terminals

Terminal symbols do not have links, they are color-marked and quoted (mostly double quotes, and single quotes in cases where double quotes occur inside terminals):

c:
    "text"

d:
    'c was defined as "text"'

Sequence of symbols

Symbols separated by spaces form a sequence. In the lexical part of the grammar, space does not map to anything; in the syntactic part, space also mean any number of whitespace characters in any combination.

e:
    a b c d

Optional symbols

Optional symbols that may evaluate to an empty symbol sequence are marked with a question sign (which is color-marked as any other BNF symbol):

f:
    e?

Iteration

‘One or many’ iteration is denoted with a plus symbol, ‘zero or many’ iteration is denoted with a star:

g:
    a* c+

Alternatives (multiple rules)

As long as choice is the outmost operation on a rule, it is denoted by new line. End of a rule is marked with an empty line. In the next example h is either c or d:

h:
    c
    d

Grouping

Symbols can be put together by the use of brackets—in this case the group is treated as one nameless symbol:

k:
    ( a b )? c

Terminal-separated iteration

For something like comma-separated lists a special kind of iteration is introduced, where it is possible to place a fixed terminal symbol (usually a comma, a dot or a semicolon) between every adjacent occurencies, but not at the end. Thus, in the example m can be a, a.a, a.a.a, etc, and n can be (), (x), (x,x), (x,x,x), etc:

m:
    { "a" "." }+

n:
    "(" { "x" "," }* ")"

Descriptive informal text

When not possible to formalise the definition of a symbol, informal text is used with different background color. For every implementation this should be replaced with a concrete solution:

o:
    We were not sure how to define it, but this symbol should not be empty.
    So, we decided to fill it up with an informal text instead.

Valid XHTML 1.0 StrictValid CSS!