2.4 Grammar notation: examples look inconsistent

Alex Buckley alex.buckley at oracle.com
Fri Sep 2 23:50:57 UTC 2016


On 8/18/2016 4:27 PM, Daniël p wrote:
> *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
> <http://docs.oracle.com/javase/specs/jls/se8/html/jls-3.html#jls-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?

This is a limitation in the toolchain that renders the JLS in HTML. The 
PDF and the printed book have correct typography, with terminals in 
fixed width font.

> *Final question:*Why is it if ( Expression ) Statement instead of if (
> Expression ) Statement?

I can't tell the difference between these alternatives.

Alex


More information about the jls-jvms-spec-comments mailing list