mojoshader_lexer.re
changeset 1123 3d842e7dd6ad
parent 1121 4142681f9fda
child 1142 7b554e065321
equal deleted inserted replaced
1122:b333c15bb984 1123:3d842e7dd6ad
    62     const uchar *cursor = (const uchar *) s->source;
    62     const uchar *cursor = (const uchar *) s->source;
    63     const uchar *token = cursor;
    63     const uchar *token = cursor;
    64     const uchar *matchptr;
    64     const uchar *matchptr;
    65     const uchar *limit = cursor + s->bytes_left;
    65     const uchar *limit = cursor + s->bytes_left;
    66     int eoi = 0;
    66     int eoi = 0;
    67     int saw_newline = 0;
       
    68 
    67 
    69 /*!re2c
    68 /*!re2c
    70     ANY = [\000-\377];
    69     ANY = [\000-\377];
    71     ANYLEGAL = [a-zA-Z0-9_/'*=+%^&|!#<>()[{}.,~^:;? \t\v\f\r\n\-\]\\];
    70     ANYLEGAL = [a-zA-Z0-9_/'*=+%^&|!#<>()[{}.,~^:;? \t\v\f\r\n\-\]\\];
    72     O = [0-7];
    71     O = [0-7];
   169 // The "*\/" is just to avoid screwing up text editor syntax highlighting.
   168 // The "*\/" is just to avoid screwing up text editor syntax highlighting.
   170 /*!re2c
   169 /*!re2c
   171     "*\/"           {
   170     "*\/"           {
   172                         if (s->report_comments)
   171                         if (s->report_comments)
   173                             RET(TOKEN_MULTI_COMMENT);
   172                             RET(TOKEN_MULTI_COMMENT);
   174                         else if (saw_newline)
       
   175                             RET('\n');
       
   176                         else if (s->report_whitespace)
   173                         else if (s->report_whitespace)
   177                             RET(' ');
   174                             RET(' ');
   178                         goto scanner_loop;
   175                         goto scanner_loop;
   179                     }
   176                     }
   180     NEWLINE         {
   177     NEWLINE         {
   181                         s->line++;
   178                         s->line++;
   182                         token = matchptr;
       
   183                         saw_newline = 1;
       
   184                         goto multilinecomment;
   179                         goto multilinecomment;
   185                     }
   180                     }
   186     "\000"          {
   181     "\000"          {
   187                         if (eoi)
   182                         if (eoi)
   188                             RET(TOKEN_INCOMPLETE_COMMENT);
   183                             RET(TOKEN_INCOMPLETE_COMMENT);
   196     matchptr = cursor;
   191     matchptr = cursor;
   197 /*!re2c
   192 /*!re2c
   198     NEWLINE         {
   193     NEWLINE         {
   199                         s->line++;
   194                         s->line++;
   200                         if (s->report_comments)
   195                         if (s->report_comments)
       
   196                         {
       
   197                             cursor = matchptr;  // so we RET('\n') next.
   201                             RET(TOKEN_SINGLE_COMMENT);
   198                             RET(TOKEN_SINGLE_COMMENT);
       
   199                         }
   202                         token = matchptr;
   200                         token = matchptr;
   203                         RET('\n');
   201                         RET('\n');
   204                     }
   202                     }
   205     "\000"          {
   203     "\000"          {
   206                         if (eoi)
   204                         if (eoi)