I have a left-recursive error with my C grammar which can be found here
http://www.archive-host.com/files/1959502/24fe084677d7655eb57ba66e1864081450017dd9/cAST.txt.
When I replace
initializer
: assignment_expression
| '{' initializer_list '}'
;
initializer
: assignment_expression
| '{' initializer_list '}'
| initializer_list
;
int k [2] = 1,4;
int k [2] = {1,4};
To do this, you'd need to introduce context sensitivity (or something on that order).
The problem is that 1,4
already has a defined meaning. It's an expression using the comma operator that evaluates the 1
, discards the result, then evaluates the 4
, which is the value of the expression as a whole.
As such, to make this work, you'd have to use a different syntax for initializers than for normal expressions (and in the process, depart pretty widely from C as it's current defined). From a purely grammatical viewpoint, that almost certainly does not need to be done with context sensitivity, but it will involve basically defining the syntax for initializers separately from/in parallel with the syntax for normal expressions, instead of using a common syntax for both.