From 2bf20f53ee16731e5580a3354c91c897e02b7e72 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Wed, 2 Mar 2011 15:42:35 +0100 Subject: Support comments. --- json-template.lisp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/json-template.lisp b/json-template.lisp index 59f2aed..30b6a94 100644 --- a/json-template.lisp +++ b/json-template.lisp @@ -48,7 +48,8 @@ do (setq in-command-p (not in-command-p) skip-newline-p (and in-command-p position - (char= (char string position) #\.))) + (member (char string position) + (list #\. #\#)))) until (null terminator))) (defun parse-template-string (stream) @@ -77,9 +78,13 @@ (destructuring-bind (command-p . data) token (if command-p - (if (char= (char data 0) #\.) - (list* :directive (parse-directive data)) - (list* :variable (parse-variable data))) + (case (char data 0) + ((#\.) + (list* :directive (parse-directive data))) + ((#\#) + (list* :comment data)) + (otherwise + (list* :variable (parse-variable data)))) (list :text data)))) (defun parse-raw-tokens (tokens) @@ -117,6 +122,8 @@ alternative)))))) else if (member token-kind '(:variable :text)) collect token + else if (eq token-kind :comment) + do (progn) else do (error "Encountered invalid token: ~S" token)))) (values result tokens))) -- cgit v1.2.3