From c2833576dc32ec143c5f4180c7688962eeec5e05 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Sun, 3 Mar 2019 10:45:43 -0500 Subject: Lexer should track newlines properly inside XML comments --- src/urweb.lex | 9 +++++---- 1 file 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]; %% - + \n => (newline yypos; continue ()); \n => (newline yypos; @@ -219,7 +218,9 @@ xint = x[0-9a-fA-F][0-9a-fA-F]; "*)" => (exitComment (); continue ()); - "" => (continue ()); + "" => (YYBEGIN XML; continue ()); + . => (continue ()); "\\\"" => (str := #"\"" :: !str; continue()); "\\'" => (str := #"'" :: !str; continue()); -- cgit v1.2.3