3 ms·
I have experience with grammars, but not with the Java one. There isn't an inherent restriction on context-free grammars why this couldn't happen. In pseudocod
by dtech 9y ago
I have experience with grammars, but not with the Java one.
There isn't an inherent restriction on context-free grammars why this couldn't happen. In pseudocode this could work fine:
classDef = accessModifier? classModifier* `class` identifier `{`
(fieldDef|methodDef|classDef)*
`}`
fieldDef = accessModifier? fieldModifier* type identifier `=` expression
classModifier = `data`
fieldModifier = `synchronized` | `final` | `volatile`
As you can see there isn't an inherent reason why the identifier rule should exclude the `data` keyword for this to work