mirror of
https://github.com/dimitri/pgloader.git
synced 2026-05-05 10:56:10 +02:00
Fix CSV separator parsing.
The previous patch introduced parser conflicts and we couldn't parse some
expressions any more, such as the following:
fields escaped by '\',
It's now possible to represent single quote as either '''', '\'', or '0x27'
and we still can parse '\' as being a single backslash character.
See #705.
This commit is contained in:
parent
bb6c3d0a32
commit
572f6a3dbe
@ -34,14 +34,22 @@
|
||||
(bind (((_ digits) hex))
|
||||
(code-char (parse-integer (text digits) :radix 16)))))
|
||||
|
||||
(defrule tab (and #\\ #\t) (:constant #\Tab))
|
||||
(defrule tab-separator (and #\' #\\ #\t #\') (:constant #\Tab))
|
||||
(defrule backslash-separator (and #\' #\\ #\') (:constant #\\))
|
||||
|
||||
(defrule single-quote (and #\\ #\') (:constant #\'))
|
||||
(defrule single-quote-separator (or (and #\' #\' #\' #\')
|
||||
(and #\' #\\ #\' #\'))
|
||||
(:constant #\'))
|
||||
|
||||
(defrule separator (and #\' (or hex-char-code tab single-quote character) #\')
|
||||
(defrule other-char-separator (and #\' (or hex-char-code character) #\')
|
||||
(:lambda (sep)
|
||||
(bind (((_ char _) sep)) char)))
|
||||
|
||||
(defrule separator (or single-quote-separator
|
||||
backslash-separator
|
||||
tab-separator
|
||||
other-char-separator))
|
||||
|
||||
;;
|
||||
;; Main CSV options (WITH ... in the command grammar)
|
||||
;;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user