aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 _]]