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:
Dimitri Fontaine 2014-10-02 17:05:35 +02:00
parent 00b002124b
commit 3c334dcdc4
4 changed files with 436 additions and 569 deletions

View File

@ -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
View 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 '_))))

View File

@ -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