From 7112782cb7cc842bdc63a4ad279ef3552fe332c6 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 12 Feb 2009 21:26:58 -0500 Subject: [PATCH] Handle lexing of comment ends better. --- mojoshader_lexer.re | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mojoshader_lexer.re b/mojoshader_lexer.re index 8cc941e7..2a426c35 100644 --- a/mojoshader_lexer.re +++ b/mojoshader_lexer.re @@ -42,6 +42,7 @@ Token preprocessor_internal_lexer(IncludeState *s) { 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 @@ scanner_loop: 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 @@ multilinecomment: } NEWLINE { s->line++; - token = cursor-1; + token = matchptr; saw_newline = 1; goto multilinecomment; } @@ -169,8 +171,9 @@ multilinecomment: 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; } */