Closed TimWhiting closed 4 years ago
Another option would be to combine the definitions of local_variable_declaration, and the top level variable declarations. You don't capture as much about the restrictions in the global scope, but I'm not sure there are that many restrictions anyways. And it's pretty much impossible to distinguish them in the grammar, unless you know whether you are in the global scope.
Fixed this. Turned out to be an issue with using _type_name rather than _type.
See the global_mutable_variables branch for a test case and an attempted failed fix for this.
The issue is that the parser falls back on statements (because we allow statements at the top level for testing). Because of that we have a lot of conflicts of various kinds (specifically looking at the _top_level_definition conflicts). This causes it to think that the following is invalid.
This is because it parses the List and final String as local variable definitions rather than top_level definitions. And since top level definitions must happen before statements, the class is unable to be parsed.
According to the spec (I'm looking at the informal spec page 188):
Currently we don't support the last entry (that is global mutable variables). Ignoring late right now of course.
There are a few different solutions as I see it.
void main(){}
void main(){}
What are your opinions? @UserNobody14