Disjunctive Normal Form

The next Stratego example, in Section 4.3 , extends prop-eval-rules to convert SPL propositions into disjunctive normal form (DNF). As the manual notes, another way to see what the dnf strategy does to a given AST is to add a Spoofax Test Language test that claims it transforms to something that it definitely does not parse to, e.g.

module manual-suite
language Spoofax-Propositional-Language

test sec4_2_test3 [[
  (r -> p & q) & p
]] run dnf to Atom("x")

The difficulty is that in a standard Spoofax language project, the error popup showing what the transformation actually does is nearly unreadable due to a tremendous amount of annotation produced by the default static analysis process.

Since in this repository we are not actually doing any (meaningful) static analysis, it includes a hack which makes the editor popup much more readable. Namely, it strips the annotation, by modifying the editor-analyze rule in trans/analysis.str like so:

module analysis

imports

  nabl2/api
  nabl2/runtime
  nabl2/shared/-

  statics

  pp

rules // Analysis

//  editor-analyze = nabl2-analyze(id)
  strip-indices : AnalysisResult([(r,Full(y,a,l,m,n))]) -> AnalysisResult([(r,Full(<nabl2--erase-ast-indices>y,a,l,m,n))])
  editor-analyze = nabl2-analyze(id); strip-indices

  [rest of file omitted]