parsing - Unreachable rules in the Java 8 CFG? -


maybe rather in-depth question has idea why in

the java languagespecification - java se 8 edition (2014-03-03)

which defines formal context-free grammar of java 8 in terms of production rules , terminals not defined rules reachable?

the specification describes dozens of rules such as

ifthenstatement:
if ( expression ) statement

or

assertstatement:
assert expression ;
assert expression : expression ;

which make perfect sense.

but strangely of defined rules not reachable others such important rule

type:
primitivetype
referencetype

in total counted following 2 rules not reachable others:

  1. packagename
  2. type

how 1 define complete java 8 cfg having unreachable rules?

often specification authors find convenient formulate rules of spec in terms of non-terminals; sometimes, however, of useful non-terminals not, technical reasons, used in main grammar. in such cases spec defines relevant non-terminals anyway, ground of rules of spec in grammatical formalism.

here, example, rule type sends pretty clear signal types either primitive types or reference types. grammar has number of places primitive types may referenced, , others reference types required. if type not reachable, need not mean syntactic grammar incomplete; may mean in fact there no places in syntactic grammar authors found useful refer type. non-terminal type may nonetheless defined, if spec authors find useful tool of exposition.

in specs appear in multiple versions, reason arises: non-terminal ceases used in main grammar, appropriate definition given avoid breaking other specs refer non-terminal, , allow other specs upgrade gracefully new version of spec containing grammar.

i not know of these reasons applies in case of these non-terminals in java 8, or whether there perhaps other reason.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -