mojoshader_compiler.c
changeset 910 3ee487d85ecb
parent 883 df6265a993bc
child 915 55b583afec46
equal deleted inserted replaced
909:1859faa45249 910:3ee487d85ecb
  2264         case ((Token) TOKEN_STRING_LITERAL): return TOKEN_HLSL_STRING_LITERAL;
  2264         case ((Token) TOKEN_STRING_LITERAL): return TOKEN_HLSL_STRING_LITERAL;
  2265         case ((Token) ':'): return TOKEN_HLSL_COLON;
  2265         case ((Token) ':'): return TOKEN_HLSL_COLON;
  2266         case ((Token) ';'): return TOKEN_HLSL_SEMICOLON;
  2266         case ((Token) ';'): return TOKEN_HLSL_SEMICOLON;
  2267         case ((Token) '{'): return TOKEN_HLSL_LBRACE;
  2267         case ((Token) '{'): return TOKEN_HLSL_LBRACE;
  2268         case ((Token) '}'): return TOKEN_HLSL_RBRACE;
  2268         case ((Token) '}'): return TOKEN_HLSL_RBRACE;
       
  2269         //case ((Token) TOKEN_PP_PRAGMA): return TOKEN_HLSL_PRAGMA;
       
  2270         //case ((Token) '\n'): return TOKEN_HLSL_NEWLINE;
  2269 
  2271 
  2270         case ((Token) TOKEN_IDENTIFIER):
  2272         case ((Token) TOKEN_IDENTIFIER):
  2271             #define tokencmp(t) ((tokenlen == strlen(t)) && (memcmp(token, t, tokenlen) == 0))
  2273             #define tokencmp(t) ((tokenlen == strlen(t)) && (memcmp(token, t, tokenlen) == 0))
  2272             //case ((Token) ''): return TOKEN_HLSL_TYPECAST
  2274             //case ((Token) ''): return TOKEN_HLSL_TYPECAST
  2273             //if (tokencmp("")) return TOKEN_HLSL_TYPE_NAME
  2275             //if (tokencmp("")) return TOKEN_HLSL_TYPE_NAME
  2447             } // for
  2449             } // for
  2448         } // for
  2450         } // for
  2449     } // for
  2451     } // for
  2450 
  2452 
  2451     // Run the preprocessor/lexer/parser...
  2453     // Run the preprocessor/lexer/parser...
       
  2454     int is_pragma = 0;   // !!! FIXME: remove this later when we can parse #pragma.
       
  2455     int skipping = 0; // !!! FIXME: remove this later when we can parse #pragma.
  2452     do {
  2456     do {
  2453         token = preprocessor_nexttoken(pp, &tokenlen, &tokenval);
  2457         token = preprocessor_nexttoken(pp, &tokenlen, &tokenval);
  2454 
  2458 
  2455         if (preprocessor_outofmemory(pp))
  2459         if (preprocessor_outofmemory(pp))
  2456         {
  2460         {
  2473         else if (tokenval == TOKEN_PREPROCESSING_ERROR)
  2477         else if (tokenval == TOKEN_PREPROCESSING_ERROR)
  2474         {
  2478         {
  2475             fail(ctx, token);  // this happens to be null-terminated.
  2479             fail(ctx, token);  // this happens to be null-terminated.
  2476             continue;
  2480             continue;
  2477         } // else if
  2481         } // else if
       
  2482 
       
  2483         else if (tokenval == TOKEN_PP_PRAGMA)
       
  2484         {
       
  2485             assert(!is_pragma);
       
  2486             is_pragma = 1;
       
  2487             skipping = 1;
       
  2488             continue;
       
  2489         }
       
  2490 
       
  2491         else if (tokenval == ((Token) '\n'))
       
  2492         {
       
  2493             assert(is_pragma);
       
  2494             is_pragma = 0;
       
  2495             skipping = 0;
       
  2496             continue;
       
  2497         }
       
  2498 
       
  2499         else if (skipping)
       
  2500         {
       
  2501             continue;
       
  2502         }
  2478 
  2503 
  2479         lemon_token = convert_to_lemon_token(ctx, token, tokenlen, tokenval);
  2504         lemon_token = convert_to_lemon_token(ctx, token, tokenlen, tokenval);
  2480         switch (lemon_token)
  2505         switch (lemon_token)
  2481         {
  2506         {
  2482             case TOKEN_HLSL_INT_CONSTANT:
  2507             case TOKEN_HLSL_INT_CONSTANT: