Skip to content

Commit

Permalink
Bogus chars in the lexer now return a token that signifies this.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Feb 13, 2009
1 parent 6ea97f6 commit 0ace954
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
1 change: 1 addition & 0 deletions mojoshader_internal.h
Expand Up @@ -326,6 +326,7 @@ typedef enum
TOKEN_PP_ENDIF,
TOKEN_PP_ERROR,
TOKEN_PP_INCOMPLETE_COMMENT,
TOKEN_PP_BAD_CHARS,
TOKEN_EOI
} Token;

Expand Down
13 changes: 5 additions & 8 deletions mojoshader_lexer.re
Expand Up @@ -54,6 +54,7 @@ scanner_loop:

/*!re2c
ANY = [\000-\377];
ANYLEGAL = [a-zA-Z0-9_/'*=+%^&|!#<>()[{}.,~^:;? \t\v\f\r\n\-\]\\];
O = [0-7];
D = [0-9];
L = [a-zA-Z_];
Expand Down Expand Up @@ -145,7 +146,7 @@ scanner_loop:
WHITESPACE { goto scanner_loop; }
NEWLINE { s->line++; RET('\n'); }
ANY { printf("bad char\n"); goto scanner_loop; }
ANY { goto bad_chars; }
*/

multilinecomment:
Expand Down Expand Up @@ -177,17 +178,13 @@ singlelinecomment:
ANY { goto singlelinecomment; }
*/

// !!! FIXME
/*
bad_chars:
if (YYLIMIT == YYCURSOR)
RET(TOKEN_BAD_TOKEN);
*/
RET(TOKEN_PP_BAD_CHARS);

/*!re2c
NEWLINE { s->line++; goto scanner_loop; }
WHITESPACE { goto scanner_loop; }
any { goto singlelinecomment; }
ANYLEGAL { cursor--; RET(TOKEN_PP_BAD_CHARS); }
ANY { goto bad_chars; }
*/

assert(0 && "Shouldn't hit this code");
Expand Down
1 change: 1 addition & 0 deletions mojoshader_preprocessor.c
Expand Up @@ -140,6 +140,7 @@ void MOJOSHADER_print_debug_token(const char *subsystem, const char *token,
TOKENCASE(TOKEN_PP_ENDIF);
TOKENCASE(TOKEN_PP_ERROR);
TOKENCASE(TOKEN_PP_INCOMPLETE_COMMENT);
TOKENCASE(TOKEN_PP_BAD_CHARS);
TOKENCASE(TOKEN_EOI);
#undef TOKENCASE

Expand Down

0 comments on commit 0ace954

Please sign in to comment.