From 87f6d3a0a00e681cefb8b94ec855fbfceeeddbfa Mon Sep 17 00:00:00 2001 From: Dimitri Fontaine Date: Sun, 31 Jul 2016 23:54:18 +0200 Subject: [PATCH] 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. --- src/parsers/command-fixed.lisp | 4 ++-- src/sources/mssql/mssql-index-filters.lisp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/parsers/command-fixed.lisp b/src/parsers/command-fixed.lisp index ef3e22e..d0ea611 100644 --- a/src/parsers/command-fixed.lisp +++ b/src/parsers/command-fixed.lisp @@ -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 diff --git a/src/sources/mssql/mssql-index-filters.lisp b/src/sources/mssql/mssql-index-filters.lisp index 3ef244f..863a83c 100644 --- a/src/sources/mssql/mssql-index-filters.lisp +++ b/src/sources/mssql/mssql-index-filters.lisp @@ -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))