Programming Languages – Scannerless Parsing and the ‘Dangling Else Problem’

ambiguitycompilerparsingprogramming-languages

I do not understand this sentence from the Wikipedia article on the Dangling Else problem:

[The Dangling Else problem] is a problem that often comes up in compiler construction, especially scannerless parsing.

Can someone explain to me how scannerless parsing techniques might exacerbate this problem? It seems to me that the problem is with the grammar — since it's ambiguous — not with the choice of parsing technique. What am I missing?

Best Answer

My best guess is that the sentence in the Wikipedia article result from a misunderstanding of E. Visser work.

Grammars for scannerless parsers (i.e. grammars describing a language as set of sequences of characters instead as a set of sequences of tokens with the tokens described separately as strings of characters) tend to have lot of ambiguities. E. Visser paper Disambiguation Filters for Scannerless Generalized LR Parsers (*) proposes several mechanisms to solve ambiguities, one of which is useful for solving the dangling else problem. But the paper do not state that the precise ambiguity named "dangling else problem" is related to scannerless parsers (nor even that the mechanism is especially useful for scannerless parsers).

The fact that it proposes a mechanism for solving it isn't an implicit statement as another ambiguity resolution mechanism (operator priority and precedence) seems also totally unrelated to the scannerless nature of the considered parsers (consider for instance that those ambiguities can't be present in regular grammars as they result from nesting, while those handled by a longest match rule can).


(*) Which is probably the paper serving as base of the Wikipedia article on scannerless parsers even if they reference another one, also by E. Visser, Scannerless Generalized-LR Parsing.