Skip to main content

Ambiguity Diagnosis



Ambiguity diagnosis suggests changes to syntax definitions to make them non-ambiguous.


The Ambiguity library, a.k.a. DrAmbiguity, contains a diagnosis tool that can help you find the causes of ambiguous parse trees and possible Disambiguations to solve them in a Syntax Definition. DrAmbiguity is a library that processes any parse forest produced by a parser generated from Rascal's Syntax Definitions. Please read Disambiguation first.


import analysis::grammars::Ambiguity;
diagnose(t); // for any t of which you know it contains an ambiguity



  • DrAmbiguity does not scale to large parse trees, so please first make your example smaller.
  • DrAmbiguity proposes several Disambiguations for each ambiguity, only few of which make sense from a language design point of view!
  • DrAmbiguity is now only a library function, while it should be integrated into the Rascal IDE