Clean-up overloaded parse rule for numbers.

The MSSQL index filters parser needs to parse digits and keep them as
text, but was piggybacking on the main parsers and the fixed file format
positions parser by re-using the rule name "number".

My understanding was that by calling `defrule' in different packages one
would create a separate set of rules. It might have been wrong from the
beginning or just changed in newer versions of esrap. Will have to
investigate more.

This fixes #434 while not applying suggested code: the comment about
where to fix the bug is spot on.

Also, it should be noted that the regression tests framework seems to be
failing us and returns success in that error case, despite code
installed to properly handle the situation. This will also need to be
investigated.
This commit is contained in:
Dimitri Fontaine 2016-07-31 23:54:18 +02:00
parent 7daee9405f
commit 87f6d3a0a0
2 changed files with 5 additions and 5 deletions

View File

@ -19,10 +19,10 @@
(defrule number (or hex-number dec-number))
(defrule field-start-position (and (? kw-from) ignore-whitespace number)
(:destructure (from ws pos) (declare (ignore from ws)) pos))
(:function third))
(defrule fixed-field-length (and (? kw-for) ignore-whitespace number)
(:destructure (for ws len) (declare (ignore for ws)) len))
(:function third))
(defrule fixed-source-field (and csv-field-name
field-start-position fixed-field-length

View File

@ -102,16 +102,16 @@
(defrule mssql-operator (and (? whitespace) (or = <> <= < >= > !=))
(:lambda (op) (second op)))
(defrule number (+ (digit-char-p character)) (:text t))
(defrule digits (+ (digit-char-p character)) (:text t))
(defrule quoted (and "'" (+ (not "'")) "'") (:lambda (q) (text (second q))))
(defrule mssql-constant-parens (and (? whitespace)
"("
(or number quoted)
(or digits quoted)
")")
(:function third))
(defrule mssql-constant-no-parens (and (? whitespace) (or number quoted))
(defrule mssql-constant-no-parens (and (? whitespace) (or digits quoted))
(:function second))
(defrule mssql-constant (or mssql-constant-parens mssql-constant-no-parens))