Fix bug in parsing of parens in some preferred content expressions. This fixes the behavior of the manual mode group.

The current manual mode preferred content expression is:

"present and (((exclude=*/archive/* and exclude=archive/*) or (not (copies=archive:1 or copies=smallarchive:1))) or (not copies=semitrusted+:1))"

The old matcher misparsed this, to basically:

OR (present and (...)) (not copies=semitrusted+:1))

The paren handling and indeed the whole conversion from tokens to the
matcher was just wrong. The new way may not be the cleverest, but I think
it is correct, and you can see how it pattern matches structurally against
the expressions when parsing them.

That expression is now parsed to:

MAnd (MOp <function>)
  (MOr (MOr (MAnd (MOp <function>) (MOp <function>)) (MNot (MOr (MOp <function>) (MOp <function>))))
    (MNot (MOp <function>)))

Which appears correct, and behaves correct in testing.

Also threw in a simplifier, so the final generated Matcher has less
unnecessary clutter in it. Mostly so that I could more easily read &
confirm them.

Also, added a simple test of the Matcher to the test suite.

There is a small chance of badly formed preferred content expressions
behaving differently than before due to this rewrite.
This commit is contained in:
Joey Hess 2013-05-24 21:33:54 -04:00
parent c84538433a
commit f8e940eb8e
4 changed files with 69 additions and 18 deletions

View file

@ -82,3 +82,8 @@ To /home/valorin/workspace/tmp/test2
Everything up-to-date
Everything up-to-date
"""]]
> It turns out there was a bug in the preferred content expression parser,
> that made it parse the expression for manual mode (but I think no other standard
> expression) quite wrong, as if it had parens in the wrong place. This explains
> the broken behavior. [[fixed|done]] --[[Joey]]