aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrmckenzie <rmckenzie92@gmail.com>2013-03-13 01:24:24 -0500
committerrmckenzie <rmckenzie92@gmail.com>2013-03-13 01:24:24 -0500
commit697caa34e65463315121f7c8864ec7d44dbe6159 (patch)
tree0678a896b9e1e77d33dc9ed73908fdb50bece4a4
parent1761132b6a3a16102cfe5d2fa940f78827adde96 (diff)
now supports limited comments
-rw-r--r--src/me/arrdem/decomp/lexer.clj2
-rw-r--r--src/me/arrdem/decomp/parser.clj15
2 files changed, 16 insertions, 1 deletions
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 "</"
+ :com-open "<!--"
+ :com-close "-->"
: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 _]]