From daniel.fp.studio at gmail.com Thu Aug 18 23:27:55 2016 From: daniel.fp.studio at gmail.com (=?UTF-8?B?RGFuacOrbCBw?=) Date: Thu, 18 Aug 2016 23:27:55 -0000 Subject: 2.4 Grammar notation: examples look inconsistent Message-ID: While reading Chapter 2 of The Java Language Specification, Java SE 8 Edition, I may have spotted an inconsistency. This topic about grammer is quite new for me though, so I might have just misinterpreted the text. If that is the case, my apologies, and I would appreciate if you would let me know what my mistake was (although I understand that this email address is not for Q & A). Yet, I have been certain enough about the problem to send a comment anyway. *The problem* In the Java Language Specification, Chapter 2, the following statements are made: *2.2. The Lexical Grammar* > These input elements, with white space (?3.6 > ) > and comments (?3.7 > ) > discarded, form the terminal symbols for the syntactic grammar for the Java > programming language and are called *tokens* (?3.5 > ). *These > tokens are the identifiers *(?3.8 > )*, > keywords *(?3.9 > )*, > literals *(?3.10 > )*, > separators *(?3.11 > )*, > and operators *(?3.12 > *)* > of the Java programming language. *2.3. The Syntactic Grammar* says that > This grammar (the syntactic grammar) has *tokens defined by the lexical > grammar as its terminal symbols*. *2.4. Grammar Notation* says that > *Terminal symbols are shown in fixed width** font* in the productions of > the lexical and syntactic grammars. This is the example shown: For example, the syntactic production: 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. So the *if*-keyword and the parentheses *()* are tokens (?3.5 ), and tokens are the terminal symbols of The Syntactic Grammer, and Terminal symbols are shown in fixed width font. Why are the tokens in this example and other examples in *italic* font instead of just fixed with font, even if they are terminal symbols and not nonterminal symbols in syntactic grammer? *Final question:*Why is it if ( Expression ) Statement instead of if ( Expression ) Statement? I hope I've made a contribution. Thank you in advance.