Java grammar (1) -- Grammar mark and java grammar mark

Source: Internet
Author: User
Tags argumentlist

Java grammar (1) -- Grammar mark and java grammar mark

========================================================== ========================================================== ============ Description: syntax tag is used to express a syntax structure Terminal symbols are 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 are to appear in a programexactly as written. nonterminal symbols are 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 then follow on succeedinglines. ========================================================== ========================================================== ======================= extended 1 (direct syntax tag): IfThenStatement: if (Expression) Statement Description: states that the nonterminal IfThenStatement represents the token if, followed by a pair token, followed by an Expression, followed by a right parenthesis token, followed by a Statement. ========================================================== ========================================================== =========================== extension 2 (recursive syntax mark): ArgumentList: ArgumentArgumentList, Argument Description: 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 isrecursive, that is to say, it is defined in terms of itself. the result is that an ArgumentListmay contain any positive number of arguments. such recursive definitions of nonterminalsare common. ========================================================== ========================================================== ======================================= extended three (optional part 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 two right-hand sides, one that omits the optional element and onethat between des it. example: 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 is an abbreviation for: BasicForStatement: for (; ForUpdate opt) Statementfor (; Expression; ForUpdate opt) Statementfor (ForInit; ForUpdate opt) statementfor (ForInit; Expression; ForUpdate opt) Statementwhich in turn is an abbreviation for: BasicForStatement: for (;) Statementfor (; ForUpdate) Statementfor (; Expression;) Statementfor (; expression; ForUpdate) Statementfor (ForInit; Expression; ForUpdate) statementso the nonterminal BasicForStatement actually has eight alternative right-hand sides. ========================================================== ========================================================== ========================================== extended four (single row multi-line expression syntax mark): ConstructorDeclaration: ConstructorModifiers opt ConstructorDeclaratorThrows opt ConstructorBody description: A very long right-hand side may be continued on a second line by substantiallyindenting this second line ===================== ========================================================== ========================================================== ================= extended 5 (multiple parts select one syntax tag): ZeroToThree: one of0 1 2 3 Description: equivalent to ZeroToThree: 0123 When the words "one of" follow the colon in a grammar definition, they signifythat each of the terminal symbols on the following line or lines is an alternativedefinition. 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 wocould make up such a token. ========================================================== ========================================================== ================================================================ extended six (Part example syntax mark): InputCharacter: UnicodeInputCharacter but not CR or LFIdentifier: IdentifierName but not a Keyword or BooleanLiteral or NullLiteral character description: the right-hand side of a lexical production may specify that certain expansions arenot permitted by using the phrase "but not" and then indicating the expansions tobe excluded. ========================================================== ========================================================== ========================================================== = extend 7 (the part is any element syntax tag in the Set): RawInputCharacter: any Unicode character Description: Finally, a few nonterminal symbols are described by a descriptive phrase in romantype in cases where it wocould be impractical to list all the alternatives.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.