diff --git a/src/parsers/command-csv.lisp b/src/parsers/command-csv.lisp index 1c2afa4..c7e4e11 100644 --- a/src/parsers/command-csv.lisp +++ b/src/parsers/command-csv.lisp @@ -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) diff --git a/src/parsers/command-utils.lisp b/src/parsers/command-utils.lisp index 4383ab3..ebc476d 100644 --- a/src/parsers/command-utils.lisp +++ b/src/parsers/command-utils.lisp @@ -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 ",")) diff --git a/src/parsers/parse-sqlite-type-name.lisp b/src/parsers/parse-sqlite-type-name.lisp index 81d9a0a..09eb0e8 100644 --- a/src/parsers/parse-sqlite-type-name.lisp +++ b/src/parsers/parse-sqlite-type-name.lisp @@ -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)