Lexer now stores token value to IncludeState.
authorRyan C. Gordon <icculus@icculus.org>
Wed, 18 Feb 2009 08:35:07 -0500
changeset 651 05ad72d120a5
parent 650 9c91067da49d
child 652 3333a0774ccc
Lexer now stores token value to IncludeState.
mojoshader_internal.h
mojoshader_lexer.re
--- a/mojoshader_internal.h	Wed Feb 18 08:30:34 2009 -0500
+++ b/mojoshader_internal.h	Wed Feb 18 08:35:07 2009 -0500
@@ -395,6 +395,7 @@
     const char *source;
     const char *token;
     unsigned int tokenlen;
+    Token tokenval;
     const unsigned char *lexer_marker;
     int report_whitespace;
     unsigned int orig_length;
--- a/mojoshader_lexer.re	Wed Feb 18 08:30:34 2009 -0500
+++ b/mojoshader_lexer.re	Wed Feb 18 08:35:07 2009 -0500
@@ -25,7 +25,7 @@
 typedef unsigned char uchar;
 
 /*!max:re2c */
-#define RET(t) do { update_state(s, eoi, cursor, token); return t; } while (0)
+#define RET(t) do { return update_state(s, eoi, cursor, token, t); } while (0)
 #define YYCTYPE uchar
 #define YYCURSOR cursor
 #define YYLIMIT limit
@@ -34,8 +34,8 @@
 
 static uchar sentinel[YYMAXFILL];
 
-static void update_state(IncludeState *s, int eoi,
-                         const uchar *cur, const uchar *tok)
+static Token update_state(IncludeState *s, int eoi, const uchar *cur,
+                          const uchar *tok, const Token val)
 {
     if (eoi)
     {
@@ -53,6 +53,8 @@
         s->token = (const char *) tok;
     } // else
     s->tokenlen = (unsigned int) (s->source - s->token);
+    s->tokenval = val;
+    return val;
 } // update_state
 
 Token preprocessor_lexer(IncludeState *s)