mojoshader_lexer.re
changeset 651 05ad72d120a5
parent 649 527cfe6f2d45
child 679 3892ebde7d99
equal deleted inserted replaced
650:9c91067da49d 651:05ad72d120a5
    23 #include "mojoshader_internal.h"
    23 #include "mojoshader_internal.h"
    24 
    24 
    25 typedef unsigned char uchar;
    25 typedef unsigned char uchar;
    26 
    26 
    27 /*!max:re2c */
    27 /*!max:re2c */
    28 #define RET(t) do { update_state(s, eoi, cursor, token); return t; } while (0)
    28 #define RET(t) do { return update_state(s, eoi, cursor, token, t); } while (0)
    29 #define YYCTYPE uchar
    29 #define YYCTYPE uchar
    30 #define YYCURSOR cursor
    30 #define YYCURSOR cursor
    31 #define YYLIMIT limit
    31 #define YYLIMIT limit
    32 #define YYMARKER s->lexer_marker
    32 #define YYMARKER s->lexer_marker
    33 #define YYFILL(n) { if ((n) == 1) { cursor = sentinel; limit = cursor + YYMAXFILL; eoi = 1; } }
    33 #define YYFILL(n) { if ((n) == 1) { cursor = sentinel; limit = cursor + YYMAXFILL; eoi = 1; } }
    34 
    34 
    35 static uchar sentinel[YYMAXFILL];
    35 static uchar sentinel[YYMAXFILL];
    36 
    36 
    37 static void update_state(IncludeState *s, int eoi,
    37 static Token update_state(IncludeState *s, int eoi, const uchar *cur,
    38                          const uchar *cur, const uchar *tok)
    38                           const uchar *tok, const Token val)
    39 {
    39 {
    40     if (eoi)
    40     if (eoi)
    41     {
    41     {
    42         s->bytes_left = 0;
    42         s->bytes_left = 0;
    43         s->source = (const char *) s->source_base + s->orig_length;
    43         s->source = (const char *) s->source_base + s->orig_length;
    51         s->bytes_left -= (unsigned int) (cur - ((const uchar *) s->source));
    51         s->bytes_left -= (unsigned int) (cur - ((const uchar *) s->source));
    52         s->source = (const char *) cur;
    52         s->source = (const char *) cur;
    53         s->token = (const char *) tok;
    53         s->token = (const char *) tok;
    54     } // else
    54     } // else
    55     s->tokenlen = (unsigned int) (s->source - s->token);
    55     s->tokenlen = (unsigned int) (s->source - s->token);
       
    56     s->tokenval = val;
       
    57     return val;
    56 } // update_state
    58 } // update_state
    57 
    59 
    58 Token preprocessor_lexer(IncludeState *s)
    60 Token preprocessor_lexer(IncludeState *s)
    59 {
    61 {
    60     const uchar *cursor = (const uchar *) s->source;
    62     const uchar *cursor = (const uchar *) s->source;