标签:
============================================================================================ 说明: 语法标记用来表达一种语法结构 Terminal symbols are shown in fixed width font in the productions of the lexical and syntactic grammars, and throughout this specification whenever the text is directly referring to such a terminal symbol. These are to appear in a program exactly as written. Nonterminal symbols are shown in italic type. The definition of a nonterminal is introduced by the name of the nonterminal being defined followed by a colon. One or more alternative right-hand sides for the nonterminal then follow on succeeding lines. ================================================================================================= 扩展一(直接式语法标记): IfThenStatement: if ( Expression ) Statement 说明: states that the nonterminal IfThenStatement represents the token if , followed by a left parenthesis token, followed by an Expression, followed by a right parenthesis token, followed by a Statement. =================================================================================================== 扩展二(递归式语法标记): ArgumentList: Argument ArgumentList , Argument 说明: states that an ArgumentList may represent either a single Argument or an ArgumentList, followed by a comma, followed by an Argument. This definition of ArgumentList is recursive, that is to say, it is defined in terms of itself. The result is that an ArgumentList may contain any positive number of arguments. Such recursive definitions of nonterminals are common. ========================================================================================================= 扩展三(部件可选式语法标记): BreakStatement: break Identifier opt ; 说明: 等价于: BreakStatement: break ; break Identifier ; The subscripted suffix "opt", which may appear after a terminal or nonterminal, indicates an optional symbol. The alternative containing the optional symbol actually specifies two right-hand sides, one that omits the optional element and one that includes it. -------------------------------------------------------------------------------------------------------- 使用例子: BasicForStatement: for ( ForInit opt ; Expression opt ; ForUpdate opt ) Statement is a convenient abbreviation for: BasicForStatement: for ( ; Expression opt ; ForUpdate opt ) Statement for ( ForInit ; Expression opt ; ForUpdate opt ) Statement which in turn is an abbreviation for: BasicForStatement: for ( ; ; ForUpdate opt ) Statement for ( ; Expression ; ForUpdate opt ) Statement for ( ForInit ; ; ForUpdate opt ) Statement for ( ForInit ; Expression ; ForUpdate opt ) Statement which in turn is an abbreviation for: BasicForStatement: for ( ; ; ) Statement for ( ; ; ForUpdate ) Statement for ( ; Expression ; ) Statement for ( ; Expression ; ForUpdate ) Statement for ( ForInit ; ; ) Statement for ( ForInit ; ; ForUpdate ) Statement for ( ForInit ; Expression ; ) Statement for ( ForInit ; Expression ; ForUpdate ) Statement so the nonterminal BasicForStatement actually has eight alternative right-hand sides. ================================================================================================================= 扩展四(单行多行式表达语法标记): ConstructorDeclaration: ConstructorModifiers opt ConstructorDeclarator Throws opt ConstructorBody 说明: A very long right-hand side may be continued on a second line by substantially indenting this second line =================================================================================================================== 扩展五(部件多选一式语法标记): ZeroToThree: one of 0 1 2 3 说明: 等价于 ZeroToThree: 0 1 2 3 When the words "one of" follow the colon in a grammar definition, they signify that each of the terminal symbols on the following line or lines is an alternative definition. -------------------------------------------------------------------------------------------------------------------- 使用例子: BooleanLiteral: one of true false in a lexical grammar production is shorthand for: BooleanLiteral: t r u e f a l s e 说明: When an alternative in a lexical production appears to be a token, it represents the sequence of characters that would make up such a token. ====================================================================================================================== 扩展六(部件例外值式语法标记): InputCharacter: UnicodeInputCharacter but not CR or LF Identifier: IdentifierName but not a Keyword or BooleanLiteral or NullLiteral --------------------------------------------------------------------------------------------------------------- 说明: The right-hand side of a lexical production may specify that certain expansions are not permitted by using the phrase "but not" and then indicating the expansions to be excluded. ========================================================================================================================= 扩展七(部件为集合中任一元素式语法标记): RawInputCharacter: any Unicode character 说明: Finally, a few nonterminal symbols are described by a descriptive phrase in roman type in cases where it would be impractical to list all the alternatives.
标签:
原文地址:http://www.cnblogs.com/xyhr/p/4240475.html