diff options
author | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2011-03-02 15:42:35 +0100 |
---|---|---|
committer | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2011-03-02 15:42:35 +0100 |
commit | 2bf20f53ee16731e5580a3354c91c897e02b7e72 (patch) | |
tree | b286a41fa76385e8d906a431a01faf06b4a44b23 | |
parent | 9c97c248407530eb0da4064b45d4b306dc2e9eb1 (diff) |
Support comments.
-rw-r--r-- | json-template.lisp | 15 |
1 files 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))) |