Skip to content

Commit

Permalink
Handle lexing of comment ends better.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Feb 13, 2009
1 parent 340a522 commit 7112782
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions mojoshader_lexer.re
Expand Up @@ -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;

Expand Down Expand Up @@ -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
"*\/" {
Expand All @@ -159,7 +161,7 @@ multilinecomment:
}
NEWLINE {
s->line++;
token = cursor-1;
token = matchptr;
saw_newline = 1;
goto multilinecomment;
}
Expand All @@ -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; }
*/

Expand Down

0 comments on commit 7112782

Please sign in to comment.