# What are the known ambiguities in C language grammar?

I have found this reference for the C syntax Backus-Naur Form (BNF). I was wondering if there are any other ambiguities in this grammar other than the infamous "dangling else"? Also how we can modify the BNF grammar to avoid those ambiguities, including the known one mentioned above?

• I posted an answer that addresses parsing issues in C in general, but not specifically for your grammar. It is a bit too long to be posted as solely a comment. If you found it to be not helpful or off topic, I will delete the answer. Thanks! – BearAqua Jun 21 '20 at 0:47

Consider the expression T ** c;. Since C supports type declarations via typedef, the parser itself cannot decide whether this is multiplication with variables T and *c or a variable declaration of a pointer to pointer c of type T**. We'll need information fed into the parser by the lexer to decide which situation we're parsing (the lexer will resolve each valid type name to a type).
Another situation similar to the situation above gives rise to an ambiguity in the C syntax: In general, statements like a +++ b are ambiguous, since both (a++) + b and a + (++b) are valid. In this kind of situation, the C compiler follows the "longest match" rule: the compiler will match against the longest sequence of characters it can match.