Rui Maciel wrote:
> I'm a Perl newbie and I've started to look into the Parse::RecDescent
> module. Meanwhile I've stumbled on a rule matching problem. I've defined
> a couple of rules to be able to deal with two different types of numbers:
> integers and decimal fractions with a single decimal place. The problem
> is that RecDescent returns false positives by matching the integer rule
> on decimal fraction numbers.
>
> As far as I can tell, that could only happen if somehow RecDescent
> doesn't make any use of any terminal symbol to specify if the rule really
> matches a pattern, which I believe could lead to a lot of false positives.
>
> So, am I missing something or is there no solution to this problem?
Rules match in the order give. Different productions within a rule are
matched in the order given. RecDescent does not try to match the
"longest" production, only the first match succeeds. This means you
need to order your productions appropriately.
given the following rules, integer would always match before fraction in
the 'number' rule but the 'number2' rule would work correctly  it would
try to match a fraction and if that failed, it would try to match an
integer.
integer: \d{1,2}
fraction: \d{1,2}\.\d
number: integer  fraction
number2: fraction  integer
[test coded snipped]

brian
