summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2019-03-03 10:45:43 -0500
committerGravatar Adam Chlipala <adam@chlipala.net>2019-03-03 10:45:43 -0500
commitc2833576dc32ec143c5f4180c7688962eeec5e05 (patch)
tree2b3f85a40250ae6ea1686cb67db445b589a10cf7
parent8d9905595994c5baac40561c862c53849bf1efe9 (diff)
Lexer should track newlines properly inside XML comments
-rw-r--r--src/urweb.lex9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/urweb.lex b/src/urweb.lex
index 368b9f1b..23c32ea1 100644
--- a/src/urweb.lex
+++ b/src/urweb.lex
@@ -174,7 +174,7 @@ fun unescape loc s =
%%
%header (functor UrwebLexFn(structure Tokens : Urweb_TOKENS));
%full
-%s COMMENT STRING CHAR XML XMLTAG;
+%s COMMENT XMLCOMMENT STRING CHAR XML XMLTAG;
id = [a-z_][A-Za-z0-9_']*;
xmlid = [A-Za-z][A-Za-z0-9_-]*;
@@ -184,13 +184,12 @@ intconst = [0-9]+;
realconst = [0-9]+\.[0-9]*;
hexconst = 0x[0-9A-F]+;
notags = ([^<{\n(]|(\([^\*<{\n]))+;
-xcom = ([^\-]|(-[^\-]))+;
oint = [0-9][0-9][0-9];
xint = x[0-9a-fA-F][0-9a-fA-F];
%%
-<INITIAL,COMMENT,XMLTAG>
+<INITIAL,COMMENT,XMLTAG,XMLCOMMENT>
\n => (newline yypos;
continue ());
<XML> \n => (newline yypos;
@@ -219,7 +218,9 @@ xint = x[0-9a-fA-F][0-9a-fA-F];
<COMMENT> "*)" => (exitComment ();
continue ());
-<XML> "<!--" {xcom} "-->" => (continue ());
+<XML> "<!--" => (YYBEGIN XMLCOMMENT; continue ());
+<XMLCOMMENT> "-->" => (YYBEGIN XML; continue ());
+<XMLCOMMENT> . => (continue ());
<STRING,CHAR> "\\\"" => (str := #"\"" :: !str; continue());
<STRING,CHAR> "\\'" => (str := #"'" :: !str; continue());