============================================================================================ Description: Syntax tags are used to express a grammatical structure terminal symbols is shown in fixed width font in the productions of the Lexicaland syntactic grammars, and Throughout this specification whenever the text isdirectly referring to such a terminal symbol. These is to appear in a programexactly as written. NonTerminal symbols is shown in italic type. The definition of a nonterminal isintroduced by the name of the nonterminal being defined followed by a colon. Oneor more alternative right-hand sides for the nonterminal and follow on succeedinglines.============================== =================================================================== extension One (direct syntax tag): ifthenstatement:if (expression) Statement Description: states that the nonterminal ifthenstatement represents the token if, followed by a leftparenthesis token, fol Lowed by an Expression, followed by a right parenthesis token,followed by a statement.=================================================================================================== extension Two (recursive syntax tag): Argumentlist:argumentargumentlist, Argument Description: States, ArgumentList may represent either a single Argument or an argumentlist,followed by a comma, foll Owed by an Argument. This definition of ArgumentList isrecursive, which is to say, it's defined in terms of itself. The result is a argumentlistmay contain any positive number of arguments. Such recursive definitions of Nonterminalsare common.============================================================== =========================================== extension Three (part optional syntax tag): Breakstatement:break Identifier opt; Description: equivalent to: Breakstatement:break; breakidentifier; The subscripted suffix "opt", which may appear after a terminal or nonterminal,indicates an optional symbol. The alternative containing the optional symbolactually specifies and right-hand sides, one that omits the optional element And Onethat includes it.----------------------------------------------------------Examples of----------------------------------------------use: basicforstatement:for (forinit opt; Expression opt; Forupdate opt) statementis a convenient abbreviation for:BasicForStatement:for (; Expression opt; Forupdate opt) statementfor (forinit; Expression opt; Forupdate opt) Statementwhich in turn are an abbreviation for:BasicForStatement:for (;; Forupdate opt) statementfor (; Expression; Forupdate opt) statementfor (forinit;; Forupdate opt) statementfor (forinit; Expression; Forupdate opt) Statementwhich in turn are an abbreviation for:BasicForStatement:for (;;) Statementfor (;; forupdate) statementfor (; Expression; ) Statementfor (; Expression; forupdate) statementfor (forinit;;) Statementfor (forinit;; forupdate) statementfor (forinit; Expression; ) Statementfor (forinit; Expression; forupdate) Statementso The nonterminal basicforstatement actually has eight alternative right-hand sides.=============== ================================================================================================== extended four (single line multiline expression syntax tag): constructordeclaration: Constructormodifiers opt constructordeclaratorthrows opt constructorbody description: A very long right-hand side may is continued on A second line by substantiallyindenting this second line============================================================= ====================================================== extension Five (component multi-select syntax tag): Zerotothree:one of0 1 2 3 Description: equivalent to zerotothree:0 123When the words "one of" follow the colon in a grammar definition, they signifythat all of the terminal symbols on the Following line or lines are an Alternativedefinition.--------------------------------------------------------------------------------------------------- -----------------Use example: Booleanliteral:one oftrue Falsein A lexical grammar production is shorthand for:booleanliteral:t R U EF A l S e description: When an alternative in a lexical production appears to be a token, it represents thesequence of characters That would make up such a token.=========================================================================================================== =========== extension Six (part exception value syntax tag): Inputcharacter:unicodeinputcharacter but not CR or lfidentifier:identifiername-not a Keyword or Booleanliteral or Nullliteral-------------------------------------------------------------------------------------------------------------- -Description: The right-hand side of a lexical production may specify this certain expansions arenot permitted by using the phrase " But isn't "and then indicating the expansions Tobe excluded.============================================================ ============================================================= extension Seven (part of any element syntax tag in the collection): Rawinputcharacter:any Unicode Character Description: Finally, a few nonterminal symbols is described by a descriptive phrase in romantype in cases where it would be impractical to list all the alternatives.
Java Grammar (1)--Grammar tags