Handle lexing of comment ends better.
authorRyan C. Gordon <icculus@icculus.org>
Thu, 12 Feb 2009 21:26:58 -0500
changeset 595 a72705c067dc
parent 594 de6f8df3b4fe
child 596 8efa254e8840
Handle lexing of comment ends better.
mojoshader_lexer.re
--- a/mojoshader_lexer.re	Thu Feb 12 20:41:01 2009 -0500
+++ b/mojoshader_lexer.re	Thu Feb 12 21:26:58 2009 -0500
@@ -42,6 +42,7 @@
 {
     const uchar *cursor = (const uchar *) s->source;
     const uchar *token;
+    const uchar *matchptr;
     const uchar *limit = cursor + s->bytes_left;
     int saw_newline = 0;
 
@@ -150,6 +151,7 @@
 multilinecomment:
     if (YYLIMIT == YYCURSOR)
         RET(TOKEN_PP_INCOMPLETE_COMMENT);
+    matchptr = cursor;
 // The "*\/" is just to avoid screwing up text editor syntax highlighting.
 /*!re2c
     "*\/"           {
@@ -159,7 +161,7 @@
                     }
     NEWLINE         {
                         s->line++;
-                        token = cursor-1;
+                        token = matchptr;
                         saw_newline = 1;
                         goto multilinecomment;
                     }
@@ -169,8 +171,9 @@
 singlelinecomment:
     if (YYLIMIT == YYCURSOR)
         RET(TOKEN_EOI);
+    matchptr = cursor;
 /*!re2c
-    NEWLINE         { s->line++; token = cursor-1; RET('\n'); }
+    NEWLINE         { s->line++; token = matchptr; RET('\n'); }
     any             { goto singlelinecomment; }
 */