@@ -35,60 +35,6 @@ int CountNewlines(LPCOLESTR psz, int cch)
35
35
return cln;
36
36
}
37
37
38
- template < typename CharT >
39
- struct AorW
40
- {
41
- };
42
-
43
- // Specialization for UTF8Char
44
- template <>
45
- struct AorW < UTF8Char >
46
- {
47
- // Expressing the args as "arrays of size N" ensures that the both args
48
- // are the same length. If not, we get a compile time error.
49
- template < size_t N >
50
- static const UTF8Char * Choose ( const char (&a)[N], const char16 (&w)[N] )
51
- {
52
- // The reinterpret_cast is necessary to go from signed to unsigned char
53
- return reinterpret_cast < const UTF8Char * >(a);
54
- }
55
-
56
- template < size_t N >
57
- static const bool Test (const char (&a)[N], const char16 (&w)[N], LPCUTF8 value)
58
- {
59
- return 0 == memcmp (a, value, (N - 1 ) * sizeof (utf8char_t ));
60
- }
61
-
62
- template < size_t N >
63
- static const bool Test (const char (&a)[N], const char16 (&w)[N], LPCUTF8 start, LPCUTF8 end)
64
- {
65
- return (end - start == N - 1 ) && (0 == memcmp (a, start, (N - 1 ) * sizeof (utf8char_t )));
66
- }
67
- };
68
-
69
- // Specialization for OLECHAR
70
- template <>
71
- struct AorW < OLECHAR >
72
- {
73
- template < size_t N >
74
- static const char16* Choose ( const char (&a)[N], const char16 (&w)[N] )
75
- {
76
- return w;
77
- }
78
-
79
- template < size_t N >
80
- static bool Test (const char (&a)[N], const char16 (&w)[N], const char16 *value)
81
- {
82
- return 0 == memcmp (w, value, (N - 1 ) * sizeof (char16));
83
- }
84
-
85
- template < size_t N >
86
- static bool Test (const char (&a)[N], const char16 (&w)[N], const char16 *start, const char16 *end)
87
- {
88
- return (end - start == N - 1 ) && (0 == memcmp (w, start, (N - 1 ) * sizeof (char16)));
89
- }
90
- };
91
-
92
38
BOOL Token::IsKeyword () const
93
39
{
94
40
// keywords (but not future reserved words)
@@ -202,7 +148,6 @@ void Scanner<EncodingPolicy>::SetText(EncodedCharPtr pszSrc, size_t offset, size
202
148
m_ptoken->tk = tkNone;
203
149
m_fIsModuleCode = (grfscr & fscrIsModuleCode) != 0 ;
204
150
m_fHadEol = FALSE ;
205
- m_fSyntaxColor = (grfscr & fscrSyntaxColor) != 0 ;
206
151
m_DeferredParseFlags = ScanFlagNone;
207
152
}
208
153
@@ -537,15 +482,6 @@ tokens Scanner<EncodingPolicy>::ScanIdentifierContinue(bool identifyKwds, bool f
537
482
tokens tk = m_phtbl->TkFromNameLen (m_tempChBuf.m_prgch , cch, IsStrictMode ());
538
483
return (!m_fYieldIsKeyword && tk == tkYIELD) || (!m_fAwaitIsKeyword && tk == tkAWAIT) ? tkID : tk;
539
484
}
540
- else if (m_fSyntaxColor)
541
- {
542
- m_ptoken->SetIdentifier (NULL );
543
- // We always need to check TkFromNameLenColor because
544
- // the main Scan switch doesn't detect all non-keyword that needs coloring
545
- // (e.g. int)
546
- int32 cch = UnescapeToTempBuf (pchMin, p);
547
- return m_phtbl->TkFromNameLenColor (m_tempChBuf.m_prgch , cch);
548
- }
549
485
550
486
// UTF16 Scanner are only for syntax coloring, so it shouldn't come here.
551
487
if (EncodingPolicy::MultiUnitEncoding && !fHasMultiChar && !fHasEscape )
@@ -995,9 +931,6 @@ tokens Scanner<EncodingPolicy>::ScanRegExpConstant(ArenaAllocator* alloc)
995
931
#ifdef PROFILE_EXEC
996
932
m_scriptContext->ProfileEnd (Js::RegexCompilePhase);
997
933
#endif
998
- if (m_fSyntaxColor)
999
- return ScanError (m_currentCharacter + e.encodedPos , tkRegExp);
1000
-
1001
934
m_currentCharacter += e.encodedPos ;
1002
935
Error (e.error );
1003
936
}
@@ -1030,7 +963,7 @@ tokens Scanner<EncodingPolicy>::ScanRegExpConstantNoAST(ArenaAllocator* alloc)
1030
963
PROBE_STACK (m_scriptContext, Js::Constants::MinStackRegex);
1031
964
}
1032
965
1033
- ThreadContext *threadContext = m_fSyntaxColor ? ThreadContext::GetContextForCurrentThread () : m_scriptContext->GetThreadContext ();
966
+ ThreadContext *threadContext = m_scriptContext->GetThreadContext ();
1034
967
UnifiedRegex::StandardChars<EncodedChar>* standardEncodedChars = threadContext->GetStandardChars ((EncodedChar*)0 );
1035
968
UnifiedRegex::StandardChars<char16>* standardChars = threadContext->GetStandardChars ((char16*)0 );
1036
969
charcount_t totalLen = 0 , bodyChars = 0 , totalChars = 0 , bodyLen = 0 ;
@@ -1050,9 +983,6 @@ tokens Scanner<EncodingPolicy>::ScanRegExpConstantNoAST(ArenaAllocator* alloc)
1050
983
}
1051
984
catch (UnifiedRegex::ParseError e)
1052
985
{
1053
- if (m_fSyntaxColor)
1054
- return ScanError (m_currentCharacter + e.encodedPos , tkRegExp);
1055
-
1056
986
m_currentCharacter += e.encodedPos ;
1057
987
Error (e.error );
1058
988
// never reached
@@ -1197,11 +1127,6 @@ tokens Scanner<EncodingPolicy>::ScanStringConstant(OLECHAR delim, EncodedCharPtr
1197
1127
}
1198
1128
1199
1129
m_currentCharacter = p - 1 ;
1200
- if (m_fSyntaxColor)
1201
- {
1202
- *pp = p - 1 ;
1203
- return ScanError (p - 1 , tkStrCon);
1204
- }
1205
1130
Error (ERRnoStrEnd);
1206
1131
1207
1132
case ' "' :
@@ -1239,11 +1164,6 @@ tokens Scanner<EncodingPolicy>::ScanStringConstant(OLECHAR delim, EncodedCharPtr
1239
1164
if (p >= last)
1240
1165
{
1241
1166
m_currentCharacter = p - 1 ;
1242
- if (m_fSyntaxColor)
1243
- {
1244
- *pp = p - 1 ;
1245
- return ScanError (p - 1 , tkStrCon);
1246
- }
1247
1167
Error (ERRnoStrEnd);
1248
1168
}
1249
1169
break ;
@@ -1499,13 +1419,6 @@ tokens Scanner<EncodingPolicy>::ScanStringConstant(OLECHAR delim, EncodedCharPtr
1499
1419
m_currentCharacter = p;
1500
1420
ScanNewLine (ch);
1501
1421
p = m_currentCharacter;
1502
- if (m_fSyntaxColor && *p == 0 )
1503
- {
1504
- // Special case for multi-line strings during colorization.
1505
- m_scanState = delim == ' "' ? ScanStateMultiLineDoubleQuoteString : ScanStateMultiLineSingleQuoteString;
1506
- *pp = p;
1507
- return tkStrCon;
1508
- }
1509
1422
continue ;
1510
1423
1511
1424
case 0 :
@@ -1515,11 +1428,6 @@ tokens Scanner<EncodingPolicy>::ScanStringConstant(OLECHAR delim, EncodedCharPtr
1515
1428
1516
1429
ReturnScanError:
1517
1430
m_currentCharacter = p - 1 ;
1518
- if (m_fSyntaxColor)
1519
- {
1520
- *pp = p - 1 ;
1521
- return ScanError (p - 1 , tkStrCon);
1522
- }
1523
1431
Error (errorType);
1524
1432
}
1525
1433
else if (stringTemplateMode)
@@ -1552,7 +1460,7 @@ tokens Scanner<EncodingPolicy>::ScanStringConstant(OLECHAR delim, EncodedCharPtr
1552
1460
LBreak:
1553
1461
bool createPid = true ;
1554
1462
1555
- if (m_fSyntaxColor || (m_DeferredParseFlags & ScanFlagSuppressStrPid) != 0 )
1463
+ if ((m_DeferredParseFlags & ScanFlagSuppressStrPid) != 0 )
1556
1464
{
1557
1465
createPid = false ;
1558
1466
@@ -1605,11 +1513,6 @@ tokens Scanner<EncodingPolicy>::SkipComment(EncodedCharPtr *pp, /* out */ bool*
1605
1513
if (*p == ' /' )
1606
1514
{
1607
1515
*pp = p + 1 ;
1608
- if (m_fSyntaxColor)
1609
- {
1610
- m_scanState = ScanStateNormal;
1611
- return tkComment;
1612
- }
1613
1516
return tkNone;
1614
1517
}
1615
1518
break ;
@@ -1634,11 +1537,6 @@ tokens Scanner<EncodingPolicy>::SkipComment(EncodedCharPtr *pp, /* out */ bool*
1634
1537
{
1635
1538
m_currentCharacter = p - 1 ;
1636
1539
*pp = p - 1 ;
1637
- if (m_fSyntaxColor)
1638
- {
1639
- m_scanState = ScanStateMultiLineComment;
1640
- return tkComment;
1641
- }
1642
1540
Error (ERRnoCmtEnd);
1643
1541
}
1644
1542
break ;
@@ -1764,26 +1662,6 @@ tokens Scanner<EncodingPolicy>::ScanCore(bool identifyKwds)
1764
1662
1765
1663
if (m_scanState && *p != 0 )
1766
1664
{
1767
- if (m_fSyntaxColor)
1768
- {
1769
- firstChar = 0 ;
1770
- secondChar = 0 ;
1771
- m_pchMinTok = p;
1772
- m_cMinTokMultiUnits = this ->m_cMultiUnits ;
1773
- switch (m_scanState)
1774
- {
1775
- case ScanStateMultiLineComment:
1776
- goto LMultiLineComment;
1777
- case ScanStateMultiLineSingleQuoteString:
1778
- ch = ' \' ' ;
1779
- m_scanState = ScanStateNormal;
1780
- goto LScanStringConstant;
1781
- case ScanStateMultiLineDoubleQuoteString:
1782
- ch = ' "' ;
1783
- m_scanState = ScanStateNormal;
1784
- goto LScanStringConstant;
1785
- }
1786
- }
1787
1665
if (m_scanState == ScanStateStringTemplateMiddleOrEnd)
1788
1666
{
1789
1667
AssertMsg (m_fStringTemplateDepth > 0 ,
@@ -1852,11 +1730,6 @@ tokens Scanner<EncodingPolicy>::ScanCore(bool identifyKwds)
1852
1730
// All other types (except errors) are handled by the outer switch.
1853
1731
}
1854
1732
Assert (chType == _C_LET || chType == _C_ERR || chType == _C_UNK || chType == _C_BKQ || chType == _C_SHP || chType == _C_AT || chType == _C_DIG);
1855
- if (m_fSyntaxColor)
1856
- {
1857
- // No need to decrement the current position pointer as scanner will continue with scan next character onwards
1858
- return ScanError (p, tkID);
1859
- }
1860
1733
m_currentCharacter = p - 1 ;
1861
1734
Error (ERRillegalChar);
1862
1735
continue ;
@@ -1869,11 +1742,6 @@ tokens Scanner<EncodingPolicy>::ScanCore(bool identifyKwds)
1869
1742
1870
1743
if (p + 1 < last)
1871
1744
{
1872
- if (m_fSyntaxColor)
1873
- {
1874
- return ScanError (p + 1 , tkID);
1875
- }
1876
-
1877
1745
// A \0 prior to the end of the text is an invalid character.
1878
1746
Error (ERRillegalChar);
1879
1747
}
@@ -1916,11 +1784,6 @@ tokens Scanner<EncodingPolicy>::ScanCore(bool identifyKwds)
1916
1784
if (p == pchT)
1917
1785
{
1918
1786
Assert (this ->PeekFirst (p, last) != ' .' );
1919
- if (m_fSyntaxColor)
1920
- {
1921
- return ScanError (m_currentCharacter + 1 , tkFltCon);
1922
- }
1923
-
1924
1787
Error (ERRbadNumber);
1925
1788
}
1926
1789
Assert (!Js::NumberUtilities::IsNan (dbl));
@@ -2029,9 +1892,6 @@ tokens Scanner<EncodingPolicy>::ScanCore(bool identifyKwds)
2029
1892
if (tkScanError == token)
2030
1893
{
2031
1894
m_currentCharacter = p;
2032
- if (m_fSyntaxColor)
2033
- return ScanError (p, tkID);
2034
-
2035
1895
Error (ERRillegalChar);
2036
1896
}
2037
1897
p = pchT;
@@ -2178,11 +2038,6 @@ tokens Scanner<EncodingPolicy>::ScanCore(bool identifyKwds)
2178
2038
case kchRET:
2179
2039
p--;
2180
2040
LCommentLineBreak:
2181
- if (m_fSyntaxColor)
2182
- {
2183
- token = tkComment;
2184
- goto LDone;
2185
- }
2186
2041
// Subtract the comment length from the total char count for the purpose
2187
2042
// of deciding whether to defer AST and byte code generation.
2188
2043
m_parser->ReduceDeferredScriptLength ((ULONG)(p - m_pchMinTok));
@@ -2227,8 +2082,6 @@ tokens Scanner<EncodingPolicy>::ScanCore(bool identifyKwds)
2227
2082
secondChar = ' \0 ' ;
2228
2083
}
2229
2084
2230
-
2231
- LMultiLineComment:
2232
2085
pchT = p;
2233
2086
commentStartLine = m_line;
2234
2087
bool containTypeDef;
@@ -2364,7 +2217,6 @@ tokens Scanner<EncodingPolicy>::ScanCore(bool identifyKwds)
2364
2217
case ' \' ' :
2365
2218
case ' "' :
2366
2219
Assert (chType == _C_QUO || chType == _C_APO);
2367
- LScanStringConstant:
2368
2220
pchT = p;
2369
2221
token = this ->ScanStringConstant ((OLECHAR)ch, &pchT);
2370
2222
p = pchT;
@@ -2384,7 +2236,7 @@ IdentPtr Scanner<EncodingPolicy>::GetSecondaryBufferAsPid()
2384
2236
{
2385
2237
bool createPid = true ;
2386
2238
2387
- if (m_fSyntaxColor || (m_DeferredParseFlags & ScanFlagSuppressStrPid) != 0 )
2239
+ if ((m_DeferredParseFlags & ScanFlagSuppressStrPid) != 0 )
2388
2240
{
2389
2241
createPid = false ;
2390
2242
}
@@ -2531,6 +2383,4 @@ HRESULT Scanner<EncodingPolicy>::SysAllocErrorLine(int32 ichMinLine, __out BSTR*
2531
2383
return S_OK;
2532
2384
}
2533
2385
2534
- template class Scanner <NullTerminatedUnicodeEncodingPolicy>;
2535
- template class Scanner <NullTerminatedUTF8EncodingPolicy>;
2536
2386
template class Scanner <NotNullTerminatedUTF8EncodingPolicy>;
0 commit comments