mojoshader_lexer.c
changeset 1123 3d842e7dd6ad
parent 1121 4142681f9fda
child 1142 7b554e065321
equal deleted inserted replaced
1122:b333c15bb984 1123:3d842e7dd6ad
    63     const uchar *cursor = (const uchar *) s->source;
    63     const uchar *cursor = (const uchar *) s->source;
    64     const uchar *token = cursor;
    64     const uchar *token = cursor;
    65     const uchar *matchptr;
    65     const uchar *matchptr;
    66     const uchar *limit = cursor + s->bytes_left;
    66     const uchar *limit = cursor + s->bytes_left;
    67     int eoi = 0;
    67     int eoi = 0;
    68     int saw_newline = 0;
       
    69 
    68 
    70 
    69 
    71 
    70 
    72     // preprocessor directives are only valid at start of line.
    71     // preprocessor directives are only valid at start of line.
    73     if (s->tokenval == ((Token) '\n'))
    72     if (s->tokenval == ((Token) '\n'))
  1137 yy185:
  1136 yy185:
  1138 	++YYCURSOR;
  1137 	++YYCURSOR;
  1139 yy186:
  1138 yy186:
  1140 	{
  1139 	{
  1141                         s->line++;
  1140                         s->line++;
  1142                         token = matchptr;
       
  1143                         saw_newline = 1;
       
  1144                         goto multilinecomment;
  1141                         goto multilinecomment;
  1145                     }
  1142                     }
  1146 yy187:
  1143 yy187:
  1147 	yych = *++YYCURSOR;
  1144 	yych = *++YYCURSOR;
  1148 	if (yych == '\n') goto yy191;
  1145 	if (yych == '\n') goto yy191;
  1163 yy192:
  1160 yy192:
  1164 	++YYCURSOR;
  1161 	++YYCURSOR;
  1165 	{
  1162 	{
  1166                         if (s->report_comments)
  1163                         if (s->report_comments)
  1167                             RET(TOKEN_MULTI_COMMENT);
  1164                             RET(TOKEN_MULTI_COMMENT);
  1168                         else if (saw_newline)
       
  1169                             RET('\n');
       
  1170                         else if (s->report_whitespace)
  1165                         else if (s->report_whitespace)
  1171                             RET(' ');
  1166                             RET(' ');
  1172                         goto scanner_loop;
  1167                         goto scanner_loop;
  1173                     }
  1168                     }
  1174 }
  1169 }
  1192 	++YYCURSOR;
  1187 	++YYCURSOR;
  1193 yy197:
  1188 yy197:
  1194 	{
  1189 	{
  1195                         s->line++;
  1190                         s->line++;
  1196                         if (s->report_comments)
  1191                         if (s->report_comments)
       
  1192                         {
       
  1193                             cursor = matchptr;  // so we RET('\n') next.
  1197                             RET(TOKEN_SINGLE_COMMENT);
  1194                             RET(TOKEN_SINGLE_COMMENT);
       
  1195                         }
  1198                         token = matchptr;
  1196                         token = matchptr;
  1199                         RET('\n');
  1197                         RET('\n');
  1200                     }
  1198                     }
  1201 yy198:
  1199 yy198:
  1202 	yych = *++YYCURSOR;
  1200 	yych = *++YYCURSOR;