Skip to content

Commit

Permalink
Treat '_' as an alphanumeric character
Browse files Browse the repository at this point in the history
Variable names that contained the '_' character were being broken up
into multiple subtokens by the highlighter, due to the highlighter's
special assembly language support. This character is now treated as a
normal alphanumeric character, to avoid this.
  • Loading branch information
Colin Ward committed Nov 6, 2024
1 parent fbec23b commit be7280a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Lex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,9 @@ const char *TLex::NextToken(TInt *a_piLength)

else
{
if (isalnum((unsigned char) *NextToken))
if (IsAlNum((unsigned char) *NextToken))
{
while ((Index < m_iLength) && isalnum((unsigned char) *NextToken) && !IsWhitespace(*NextToken) &&
while ((Index < m_iLength) && IsAlNum((unsigned char) *NextToken) && !IsWhitespace(*NextToken) &&
(!IsQuote(*NextToken)))
{
++NextToken;
Expand All @@ -324,7 +324,7 @@ const char *TLex::NextToken(TInt *a_piLength)
}
else
{
while ((Index < m_iLength) && !isalnum((unsigned char) *NextToken) && !IsWhitespace(*NextToken) &&
while ((Index < m_iLength) && !IsAlNum((unsigned char) *NextToken) && !IsWhitespace(*NextToken) &&
!IsQuote(*NextToken))
{
++NextToken;
Expand Down
7 changes: 7 additions & 0 deletions Lex.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ class TLex
TInt m_iQuotesLength; /**< Number of characters of quotes to be checked */
TInt m_iWhitespaceLength; /**< Number of characters of white space to be checked */

private:

inline bool IsAlNum(unsigned char a_character)
{
return (a_character == '_') ? true : isalnum(a_character);
}

public:

TLex(const char *a_pccString, TInt a_iLength);
Expand Down

0 comments on commit be7280a

Please sign in to comment.