NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

2.2 Grammar notation

Lexical and syntactic grammars for C# are interspersed throughout this specification. The lexical grammar defines how characters can be combined to form tokens; the syntactic grammar defines how tokens can be combined to form C# programs.

Grammar productions include non-terminal symbols and terminal symbols. In grammar productions, non-terminal symbols are shown in italic type, and terminal symbols are shown in a fixed-width font. Each non-terminal is defined by a set of productions. The first line of a set of productions is the name of the non-terminal, followed by a colon. Each successive indented line contains the right-hand side for a production that has the non-terminal symbol as the left-hand side. The example:

nonsense:
terminal1
terminal2

defines the nonsense non-terminal as having two productions, one with terminal1 on the right-hand side and one with terminal2 on the right-hand side.

Alternatives are normally listed on separate lines, though in cases where there are many alternatives, the phrase "one of" precedes a list of the options. This is simply shorthand for listing each of the alternatives on a separate line. The example:

letter: one of
A B C a b c

is shorthand for:

letter: one of
A
B
C
a
b
c

A subscripted suffix "opt", as in identifieropt, is used as shorthand to indicate an optional symbol. The example:

whole:
first-part second-partopt last-part

is shorthand for:

whole:
first-part last-part
first-part second-part last-part