@@ -849,8 +849,9 @@ static void tokenize(const unsigned char *p_text, uint4 p_length, uint4 p_in_nes
849
849
}
850
850
else
851
851
{
852
- switch (type_table[t_char])
853
- {
852
+ uint8_t t_current_type = type_table[t_char];
853
+ switch (t_current_type)
854
+ {
854
855
case ST_SPC:
855
856
t_class = COLOURIZE_CLASS_WHITESPACE;
856
857
while (t_index < p_length && type_table[(t_char = next_valid_char (p_text, t_index))] == ST_SPC)
@@ -992,17 +993,33 @@ static void tokenize(const unsigned char *p_text, uint4 p_length, uint4 p_in_nes
992
993
break ;
993
994
994
995
case ST_LIT:
995
- t_char = next_valid_char (p_text, t_index);
996
- while (t_index < p_length && type_table[t_char] != ST_EOL && (type_table[t_char] != ST_LIT))
996
+ case ST_ESCLIT:
997
+ {
998
+ uint8_t t_previous_type = t_current_type;
999
+ t_char = next_valid_char (p_text, t_index);
1000
+ bool t_escaping = false ;
1001
+ while (t_index < p_length &&
1002
+ type_table[t_char] != ST_EOL &&
1003
+ ((t_current_type == ST_ESCLIT && t_escaping) ||
1004
+ (type_table[t_char] != t_current_type)))
1005
+ {
1006
+ t_previous_type = type_table[t_char];
1007
+ if (t_previous_type == ST_ESC && !t_escaping)
1008
+ t_escaping = true ;
1009
+ else if (t_escaping)
1010
+ t_escaping = false ;
997
1011
t_char = next_valid_char (p_text, t_index);
998
- if (t_index < p_length && type_table[t_char] == ST_LIT)
1012
+ }
1013
+
1014
+ if (t_index < p_length && type_table[t_char] == t_current_type)
999
1015
{
1000
1016
t_char = next_valid_char (p_text, t_index);
1001
1017
t_class = COLOURIZE_CLASS_STRING;
1002
1018
}
1003
1019
else
1004
1020
t_class = COLOURIZE_CLASS_ERROR;
1005
1021
t_end = t_index;
1022
+ }
1006
1023
break ;
1007
1024
1008
1025
case ST_NUM:
@@ -1215,7 +1232,8 @@ static void tokenize_stringref(MCStringRef p_string, uint4 p_in_nesting, uint4&
1215
1232
}
1216
1233
else
1217
1234
{
1218
- switch (get_codepoint_type (t_char))
1235
+ uint8_t t_current_type = get_codepoint_type (t_char);
1236
+ switch (t_current_type)
1219
1237
{
1220
1238
case ST_SPC:
1221
1239
t_class = COLOURIZE_CLASS_WHITESPACE;
@@ -1367,17 +1385,34 @@ static void tokenize_stringref(MCStringRef p_string, uint4 p_in_nesting, uint4&
1367
1385
break ;
1368
1386
1369
1387
case ST_LIT:
1370
- t_char = next_valid_unichar (p_string, t_index);
1371
- while (t_index < t_length && get_codepoint_type (t_char) != ST_EOL && get_codepoint_type (t_char) != ST_LIT)
1372
- t_char = next_valid_unichar (p_string, t_index);
1373
- if (t_index < t_length && get_codepoint_type (t_char) == ST_LIT)
1388
+ case ST_ESCLIT:
1389
+ {
1390
+ uint8_t t_previous_type = t_current_type;
1391
+ t_char = next_valid_unichar (p_string, t_index);
1392
+ bool t_escaping = false ;
1393
+
1394
+ while (t_index < t_length &&
1395
+ get_codepoint_type (t_char) != ST_EOL &&
1396
+ ((t_current_type == ST_ESCLIT && t_escaping) ||
1397
+ (get_codepoint_type (t_char) != t_current_type)))
1398
+ {
1399
+ t_previous_type = get_codepoint_type (t_char);
1400
+ if (t_previous_type == ST_ESC && !t_escaping)
1401
+ t_escaping = true ;
1402
+ else if (t_escaping)
1403
+ t_escaping = false ;
1404
+ t_char = next_valid_unichar (p_string, t_index);
1405
+ }
1406
+
1407
+ if (t_index < t_length && get_codepoint_type (t_char) == t_current_type)
1374
1408
{
1375
1409
t_char = next_valid_unichar (p_string, t_index);
1376
1410
t_class = COLOURIZE_CLASS_STRING;
1377
1411
}
1378
1412
else
1379
1413
t_class = COLOURIZE_CLASS_ERROR;
1380
1414
t_end = t_index;
1415
+ }
1381
1416
break ;
1382
1417
1383
1418
case ST_NUM:
0 commit comments