summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmlexer.cpp33
1 files changed, 17 insertions, 16 deletions
diff --git a/xfa/fxfa/fm2js/cxfa_fmlexer.cpp b/xfa/fxfa/fm2js/cxfa_fmlexer.cpp
index d217587e66..5e5761702b 100644
--- a/xfa/fxfa/fm2js/cxfa_fmlexer.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmlexer.cpp
@@ -30,6 +30,13 @@ bool IsInitialIdentifierCharacter(wchar_t c) {
c == 0x0021; // '!'
}
+bool IsWhitespaceCharacter(wchar_t c) {
+ return c == 0x0009 || // Horizontal tab
+ c == 0x000B || // Vertical tab
+ c == 0x000C || // Form feed
+ c == 0x0020; // Space
+}
+
const XFA_FMKeyword keyWords[] = {
{TOKand, 0x00000026, L"&"},
{TOKlparen, 0x00000028, L"("},
@@ -168,23 +175,21 @@ std::unique_ptr<CXFA_FMToken> CXFA_FMLexer::NextToken() {
}
switch (*m_cursor) {
- case 0x0A:
+ case '\n':
++m_current_line;
m_token->m_line_num = m_current_line;
++m_cursor;
break;
- case 0x0D:
+ case '\r':
++m_cursor;
break;
- case ';': {
+ case ';':
AdvanceForComment();
break;
- }
- case '"': {
+ case '"':
m_token->m_type = TOKstring;
AdvanceForString();
return std::move(m_token);
- }
case '0':
case '1':
case '2':
@@ -194,11 +199,10 @@ std::unique_ptr<CXFA_FMToken> CXFA_FMLexer::NextToken() {
case '6':
case '7':
case '8':
- case '9': {
+ case '9':
m_token->m_type = TOKnumber;
AdvanceForNumber();
return std::move(m_token);
- }
case '=':
++m_cursor;
if (m_cursor > m_end) {
@@ -343,20 +347,17 @@ std::unique_ptr<CXFA_FMToken> CXFA_FMLexer::NextToken() {
m_token->m_type = TOKdot;
}
return std::move(m_token);
- case 0x09:
- case 0x0B:
- case 0x0C:
- case 0x20:
- ++m_cursor;
- break;
- default: {
+ default:
+ if (IsWhitespaceCharacter(*m_cursor)) {
+ ++m_cursor;
+ break;
+ }
if (!IsInitialIdentifierCharacter(*m_cursor)) {
RaiseError();
return nullptr;
}
AdvanceForIdentifier();
return std::move(m_token);
- }
}
}