Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

C) Respect dependencies when working on a left-edge ambiguity - one symbol appears in several subrules at the first place. The problem in such a case is that the context is provided by other rules and may cause a new ambiguity. An example of a real case is "s: A | (A B)?;". If one were to solve this with left-factoring, one would have to create "A? B?" and check for invalid combinations. Unfortunately, there is some interaction in this situation: "r: A (s | A? B);". Now the input sequence "A B" can be recognized via s, too - which was not possible in the original variant. The proper way to handle this rule is to use syntactic predicates and not left-factoring.

D) Never use "." in syntactic predicates - in many cases this will still choose the first path instead of the second one, as a key sequence for the first path may show up much later in the source file. "." will then simply include the key sequence for the second path.

...