mirror of
https://github.com/dimitri/pgloader.git
synced 2026-05-04 10:31:02 +02:00
Refactor the main parser to use the bind macro.
The metabang-bind lib offers a nice bind macro that solves the problem of ignoring bindings in destructuring-bind, and allows a let* approach to nested destructuring (wven when mixed with let declarations). Using that lib (that we already indirectly depend on anyway) simplifies the parser code substantially.
This commit is contained in:
parent
00b002124b
commit
3c334dcdc4
@ -30,6 +30,7 @@
|
||||
#:cl-base64 ; Decode base64 data
|
||||
#:trivial-backtrace ; For --debug cli usage
|
||||
#:cl-markdown ; To produce the website
|
||||
#:metabang-bind ; the bind macro
|
||||
)
|
||||
:components
|
||||
((:module "src"
|
||||
@ -38,6 +39,10 @@
|
||||
(:file "package" :depends-on ("params"))
|
||||
(:file "queue" :depends-on ("params" "package"))
|
||||
|
||||
(:module "monkey"
|
||||
:components
|
||||
((:file "bind")))
|
||||
|
||||
(:module "utils"
|
||||
:depends-on ("package" "params")
|
||||
:components
|
||||
@ -67,7 +72,7 @@
|
||||
"schema"))))
|
||||
|
||||
(:module "parsers"
|
||||
:depends-on ("params" "package" "utils" "pgsql")
|
||||
:depends-on ("params" "package" "utils" "pgsql" "monkey")
|
||||
:components
|
||||
((:file "parse-ini")
|
||||
(:file "parser")
|
||||
|
||||
10
src/monkey/bind.lisp
Normal file
10
src/monkey/bind.lisp
Normal file
@ -0,0 +1,10 @@
|
||||
;;;
|
||||
;;; Monkey patch metaband-bind macro to ignore nil:
|
||||
;;;
|
||||
;;; https://github.com/gwkkwg/metabang-bind/issues/9
|
||||
;;;
|
||||
|
||||
(in-package #:metabang.bind)
|
||||
|
||||
(defun var-ignorable-p (var)
|
||||
(and (symbolp var) (string= (symbol-name var) (symbol-name '_))))
|
||||
@ -158,7 +158,8 @@
|
||||
(:export #:read-queries))
|
||||
|
||||
(defpackage #:pgloader.parser
|
||||
(:use #:cl #:esrap #:pgloader.params #:pgloader.utils #:pgloader.sql)
|
||||
(:use #:cl #:esrap #:metabang.bind
|
||||
#:pgloader.params #:pgloader.utils #:pgloader.sql)
|
||||
(:import-from #:alexandria #:read-file-into-string)
|
||||
(:import-from #:pgloader.pgsql
|
||||
#:with-pgsql-transaction
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user