From 697caa34e65463315121f7c8864ec7d44dbe6159 Mon Sep 17 00:00:00 2001 From: rmckenzie Date: Wed, 13 Mar 2013 01:24:24 -0500 Subject: now supports limited comments --- src/me/arrdem/decomp/lexer.clj | 2 ++ src/me/arrdem/decomp/parser.clj | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/me/arrdem/decomp/lexer.clj b/src/me/arrdem/decomp/lexer.clj index 15ae7d9..0f7ae40 100644 --- a/src/me/arrdem/decomp/lexer.clj +++ b/src/me/arrdem/decomp/lexer.clj @@ -4,6 +4,8 @@ (deflexer html-base :cclose "" :open "<" :close ">" :assign "=" diff --git a/src/me/arrdem/decomp/parser.clj b/src/me/arrdem/decomp/parser.clj index e503e36..0e5be53 100644 --- a/src/me/arrdem/decomp/parser.clj +++ b/src/me/arrdem/decomp/parser.clj @@ -13,6 +13,8 @@ (deftoken closetok :close) (deftoken cclosetok :cclose) (deftoken chrtok :chr) +(deftoken comopen :com-open) +(deftoken comclose :com-close) (def chr (fnp/semantics @@ -50,11 +52,21 @@ wordtok closetok)) +(def html-comment + (fnp/constant-semantics + (fnp/conc + comopen + (fnp/rep* (fnp/except fnp/anything comclose)) + comclose) + nil)) + (declare html-ast) (defn reduce-strs [s] (reduce (fn [acc n] - (cond (and (string? (last acc)) + (cond (nil? n) acc + + (and (string? (last acc)) (string? n)) (concat (butlast acc) [(str (last acc) " " n)]) @@ -83,6 +95,7 @@ (fnp/alt word chr + html-comment html-ast)) html-closetag) (fn [[o v _]] -- cgit v1.2.3-18-g5258