From 424bef0d0aac2a5a8607cf9f76a6def5ee0ca183 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 19 Apr 2022 23:42:26 +0200 Subject: biblio: Replace template interpreter with a macro (a "compiler"). This allows us to catch invalid templates at macro-expansion time and is more efficient. * src/guile/skribilo/biblio/template.scm (evaluate-bib-entry-template): Remove. (define-template-engine, bibliography-template): New macros. (output-bib-entry-template): Rewrite and remove 'get-field' optional argument. (make-bib-entry-template/default, make-bib-entry-template/skribe): Use 'bibliography-template' instead of quasiquote/unquote. * src/guile/skribilo/package/jfp.scm (le): Likewise. * src/guile/skribilo/package/lncs.scm (bib-entry-template): Likewise. * src/guile/skribilo/biblio.scm (&biblio-template-error): Remove. (handle-biblio-error): Adjust accordingly. * tests/biblio.test: New file. * tests/Makefile.am (TESTS): Add it. --- src/guile/skribilo/biblio.scm | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'src/guile/skribilo/biblio.scm') diff --git a/src/guile/skribilo/biblio.scm b/src/guile/skribilo/biblio.scm index 9d83cde..7d95d51 100644 --- a/src/guile/skribilo/biblio.scm +++ b/src/guile/skribilo/biblio.scm @@ -55,13 +55,11 @@ bib-sort-refs/number ;; error conditions - &biblio-error &biblio-entry-error &biblio-template-error + &biblio-error &biblio-entry-error &biblio-parse-error - biblio-error? biblio-entry-error? biblio-template-error? + biblio-error? biblio-entry-error? biblio-parse-error? biblio-entry-error:entry - biblio-template-error:expression - biblio-template-error:template biblio-parse-error:sexp)) ;;; Commentary: @@ -86,11 +84,6 @@ biblio-entry-error? (entry biblio-entry-error:entry)) -(define-condition-type &biblio-template-error &biblio-error - biblio-template-error? - (expression biblio-template-error:expression) - (template biblio-template-error:template)) - (define-condition-type &biblio-parse-error &biblio-error biblio-parse-error? (sexp biblio-parse-error:sexp)) @@ -110,11 +103,6 @@ (format (current-error-port) (G_ "invalid bibliography entry: ~a~%") entry)))) - ((biblio-template-error? c) - (format (current-error-port) - (G_ "invalid bibliography entry template: '~a', in '~a'~%") - (biblio-template-error:expression c) - (biblio-template-error:template c))) ((biblio-parse-error? c) (format (current-error-port) (G_ "invalid bibliography entry s-exp: '~a'~%") -- cgit v1.2.3