Improve SQLite type names parsing.

Allow spaces in more random places, as SQLite doesn't seem to normalize the
user input. Fixes #548 again.
This commit is contained in:
Dimitri Fontaine 2018-11-07 11:01:06 +01:00
parent f8460c1705
commit 207cd82726
3 changed files with 16 additions and 11 deletions

View File

@ -231,11 +231,6 @@
(destructuring-bind (field1 fields) source
(list* field1 fields))))
(defrule open-paren (and ignore-whitespace #\( ignore-whitespace)
(:constant :open-paren))
(defrule close-paren (and ignore-whitespace #\) ignore-whitespace)
(:constant :close-paren))
(defrule having-fields (and kw-having kw-fields) (:constant nil))
(defrule csv-source-field-list (and (? having-fields)

View File

@ -57,3 +57,11 @@
quoted-namestring
namestring))
(defrule open-paren (and ignore-whitespace #\( ignore-whitespace)
(:constant :open-paren))
(defrule close-paren (and ignore-whitespace #\) ignore-whitespace)
(:constant :close-paren))
(defrule comma-separator (and ignore-whitespace #\, ignore-whitespace)
(:constant ","))

View File

@ -15,14 +15,16 @@
(? " "))
(:lambda (noise) (second noise)))
(defrule sqlite-single-typemod (and #\( (+ (digit-char-p character)) #\))
(defrule sqlite-single-typemod (and open-paren
(+ (digit-char-p character))
close-paren)
(:lambda (st) (cons (parse-integer (text (second st))) nil)))
(defrule sqlite-double-typemod (and #\(
(defrule sqlite-double-typemod (and open-paren
(+ (digit-char-p character))
(* (or #\, #\Space))
comma-separator
(+ (digit-char-p character))
#\))
close-paren)
(:lambda (dt) (cons (parse-integer (text (second dt)))
(parse-integer (text (fourth dt))))))
@ -31,9 +33,9 @@
(defrule sqlite-type-name (and (* extra-qualifiers)
(+ (alpha-char-p character))
(* extra-qualifiers)
(* #\Space)
ignore-whitespace
(? sqlite-typemod)
(* #\Space)
ignore-whitespace
(* extra-qualifiers))
(:lambda (tn) (list (text (second tn))
(fifth tn)