5. Notational conventions

Lexical and syntactic grammars for C# are interspersed throughout this
specification. The lexical grammar
defines how characters can be combined to form tokens (§9.4), the minimal
lexical elements of the language.
The syntactic grammar defines how tokens can be combined to make valid C#
programs.
Grammar productions include both non-terminal and terminal symbols. In
grammar productions, nonterminal
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 nonterminal,
followed by one or two colons. One colon is used for a production in the
syntactic grammar, two
colons for a production in the lexical grammar. Each successive indented
line contains the right-hand side
for a production that has the non-terminal symbol as the left-hand side.
For example:
class-modifier:
new
public
protected
internal
private
abstract
sealed
defines the class-modifier non-terminal as having seven productions.
Alternatives are normally listed on separate lines, as shown above, 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. For example:
decimal-digit: one of
0 1 2 3 4 5 6 7 8 9
is equivalent to:
decimal-digit:
0
1
2
3
4
5
6
7
8
9
A subscripted suffix .opt., as in identifieropt, is used as shorthand to
indicate an optional symbol. The
example:
for-statement:
for ( for-initializeropt ; for-conditionopt ; for-iteratoropt )
embedded-statement
is equivalent to:
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值