summaryrefslogtreecommitdiff
path: root/xfa/fxfa/fm2js
diff options
context:
space:
mode:
authordan sinclair <dsinclair@chromium.org>2017-05-17 22:17:34 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-05-18 15:27:37 +0000
commit2034b941dfa07d30c286bfcceffd6904740ac446 (patch)
tree1bc3c9be4d3108b53ced4db9837187dddf6df88d /xfa/fxfa/fm2js
parentcfd56852b6375d2b4eea473399231caf7dcdbf36 (diff)
downloadpdfium-2034b941dfa07d30c286bfcceffd6904740ac446.tar.xz
Remove CXFA_FMErrorInfo
This Cl removes the CXFA_FMErrorInfo class. The message was never output, just used as a flag to determine if there was an error. The class has been replaced with a boolean. Change-Id: I1cde99ce6957f5f8c6be0755a198d80ec8378b3a Reviewed-on: https://pdfium-review.googlesource.com/5653 Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/fm2js')
-rw-r--r--xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp6
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmerrorinfo.cpp20
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmerrorinfo.h31
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmlexer.cpp48
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmlexer.h8
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmlexer_unittest.cpp47
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmparse.cpp149
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmparse.h8
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmparse_unittest.cpp23
9 files changed, 122 insertions, 218 deletions
diff --git a/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
index f191707ca3..a9ce54d6a6 100644
--- a/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
@@ -6119,11 +6119,9 @@ bool CXFA_FM2JSContext::Translate(const CFX_WideStringC& wsFormcalc,
return true;
}
- CXFA_FMErrorInfo errorInfo;
- CXFA_FMParse parser(wsFormcalc, &errorInfo);
-
+ CXFA_FMParse parser(wsFormcalc);
std::unique_ptr<CXFA_FMFunctionDefinition> func = parser.Parse();
- if (!errorInfo.message.IsEmpty())
+ if (parser.HasError())
return false;
if (!func->ToJavaScript(*wsJavascript))
diff --git a/xfa/fxfa/fm2js/cxfa_fmerrorinfo.cpp b/xfa/fxfa/fm2js/cxfa_fmerrorinfo.cpp
deleted file mode 100644
index 3e2d5f8eb9..0000000000
--- a/xfa/fxfa/fm2js/cxfa_fmerrorinfo.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "xfa/fxfa/fm2js/cxfa_fmerrorinfo.h"
-
-const wchar_t kFMErrUnsupportedChar[] = L"unsupported char '%c'";
-const wchar_t kFMErrBadSuffixNumber[] = L"bad suffix on number";
-const wchar_t kFMErrExpectedIdentifier[] =
- L"expected identifier instead of '%.16s'";
-const wchar_t kFMErrExpectedToken[] = L"expected '%.16s' instead of '%.16s'";
-const wchar_t kFMErrExpectedEndIf[] = L"expected 'endif' instead of '%.16s'";
-const wchar_t kFMErrUnexpectedExpression[] = L"unexpected expression '%.16s'";
-const wchar_t kFMErrExpectedNonEmptyExpression[] =
- L"expected non-empty expression";
-const wchar_t kFMErrLongAssignmentChain[] =
- L"long assignment chains are unsupported";
-const wchar_t kFMErrEndOfInput[] = L"unexpected end of input";
diff --git a/xfa/fxfa/fm2js/cxfa_fmerrorinfo.h b/xfa/fxfa/fm2js/cxfa_fmerrorinfo.h
deleted file mode 100644
index c9d9510fb0..0000000000
--- a/xfa/fxfa/fm2js/cxfa_fmerrorinfo.h
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FXFA_FM2JS_CXFA_FMERRORINFO_H_
-#define XFA_FXFA_FM2JS_CXFA_FMERRORINFO_H_
-
-#include "core/fxcrt/fx_string.h"
-#include "core/fxcrt/fx_system.h"
-
-extern const wchar_t kFMErrUnsupportedChar[];
-extern const wchar_t kFMErrBadSuffixNumber[];
-extern const wchar_t kFMErrExpectedIdentifier[];
-extern const wchar_t kFMErrExpectedToken[];
-extern const wchar_t kFMErrExpectedEndIf[];
-extern const wchar_t kFMErrUnexpectedExpression[];
-extern const wchar_t kFMErrExpectedNonEmptyExpression[];
-extern const wchar_t kFMErrLongAssignmentChain[];
-extern const wchar_t kFMErrEndOfInput[];
-
-class CXFA_FMErrorInfo {
- public:
- CXFA_FMErrorInfo() : linenum(0) {}
- ~CXFA_FMErrorInfo() {}
- uint32_t linenum;
- CFX_WideString message;
-};
-
-#endif // XFA_FXFA_FM2JS_CXFA_FMERRORINFO_H_
diff --git a/xfa/fxfa/fm2js/cxfa_fmlexer.cpp b/xfa/fxfa/fm2js/cxfa_fmlexer.cpp
index 18f915f198..db7cc956e8 100644
--- a/xfa/fxfa/fm2js/cxfa_fmlexer.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmlexer.cpp
@@ -94,12 +94,11 @@ CXFA_FMToken::CXFA_FMToken() : m_type(TOKreserver), m_uLinenum(1) {}
CXFA_FMToken::CXFA_FMToken(uint32_t uLineNum)
: m_type(TOKreserver), m_uLinenum(uLineNum) {}
-CXFA_FMLexer::CXFA_FMLexer(const CFX_WideStringC& wsFormCalc,
- CXFA_FMErrorInfo* pErrorInfo)
+CXFA_FMLexer::CXFA_FMLexer(const CFX_WideStringC& wsFormCalc)
: m_ptr(wsFormCalc.c_str()),
m_end(m_ptr + wsFormCalc.GetLength() - 1),
m_uCurrentLine(1),
- m_pErrorInfo(pErrorInfo) {}
+ m_LexerError(false) {}
CXFA_FMLexer::~CXFA_FMLexer() {}
@@ -119,7 +118,7 @@ std::unique_ptr<CXFA_FMToken> CXFA_FMLexer::Scan() {
auto p = pdfium::MakeUnique<CXFA_FMToken>(m_uCurrentLine);
if (!IsValid(m_ptr)) {
ch = *m_ptr;
- Error(kFMErrUnsupportedChar, ch);
+ m_LexerError = true;
return p;
}
@@ -134,7 +133,7 @@ std::unique_ptr<CXFA_FMToken> CXFA_FMLexer::Scan() {
ch = *m_ptr;
if (!IsValid(m_ptr)) {
- Error(kFMErrUnsupportedChar, ch);
+ m_LexerError = true;
return p;
}
@@ -190,7 +189,7 @@ std::unique_ptr<CXFA_FMToken> CXFA_FMLexer::Scan() {
}
} else {
ch = *m_ptr;
- Error(kFMErrUnsupportedChar, ch);
+ m_LexerError = true;
}
return p;
case '<':
@@ -213,7 +212,7 @@ std::unique_ptr<CXFA_FMToken> CXFA_FMLexer::Scan() {
}
} else {
ch = *m_ptr;
- Error(kFMErrUnsupportedChar, ch);
+ m_LexerError = true;
}
return p;
case '>':
@@ -233,7 +232,7 @@ std::unique_ptr<CXFA_FMToken> CXFA_FMLexer::Scan() {
}
} else {
ch = *m_ptr;
- Error(kFMErrUnsupportedChar, ch);
+ m_LexerError = true;
}
return p;
case ',':
@@ -285,7 +284,7 @@ std::unique_ptr<CXFA_FMToken> CXFA_FMLexer::Scan() {
if (!IsValid(m_ptr)) {
ch = *m_ptr;
- Error(kFMErrUnsupportedChar, ch);
+ m_LexerError = true;
return p;
}
ch = *m_ptr;
@@ -323,7 +322,7 @@ std::unique_ptr<CXFA_FMToken> CXFA_FMLexer::Scan() {
}
} else {
ch = *m_ptr;
- Error(kFMErrUnsupportedChar, ch);
+ m_LexerError = true;
}
return p;
case 0x09:
@@ -346,7 +345,7 @@ const wchar_t* CXFA_FMLexer::Number(CXFA_FMToken* t, const wchar_t* p) {
if (p)
wcstod(const_cast<wchar_t*>(p), &pEnd);
if (pEnd && FXSYS_iswalpha(*pEnd)) {
- Error(kFMErrBadSuffixNumber);
+ m_LexerError = true;
return pEnd;
}
@@ -359,7 +358,7 @@ const wchar_t* CXFA_FMLexer::String(CXFA_FMToken* t, const wchar_t* p) {
++p;
if (p > m_end) {
- Error(kFMErrEndOfInput);
+ m_LexerError = true;
return p;
}
@@ -368,7 +367,7 @@ const wchar_t* CXFA_FMLexer::String(CXFA_FMToken* t, const wchar_t* p) {
if (!IsValid(p)) {
ch = *p;
t->m_wstring = CFX_WideStringC(pStart, (p - pStart));
- Error(kFMErrUnsupportedChar, ch);
+ m_LexerError = true;
return p;
}
@@ -376,7 +375,7 @@ const wchar_t* CXFA_FMLexer::String(CXFA_FMToken* t, const wchar_t* p) {
if (ch != '"') {
// We've hit the end of the input, return the string.
if (p > m_end) {
- Error(kFMErrEndOfInput);
+ m_LexerError = true;
return p;
}
ch = *p;
@@ -389,7 +388,7 @@ const wchar_t* CXFA_FMLexer::String(CXFA_FMToken* t, const wchar_t* p) {
if (!IsValid(p)) {
ch = *p;
t->m_wstring = CFX_WideStringC(pStart, (p - pStart));
- Error(kFMErrUnsupportedChar, ch);
+ m_LexerError = true;
return p;
}
ch = *p;
@@ -398,7 +397,7 @@ const wchar_t* CXFA_FMLexer::String(CXFA_FMToken* t, const wchar_t* p) {
++p;
if (p > m_end) {
- Error(kFMErrEndOfInput);
+ m_LexerError = true;
return p;
}
ch = *p;
@@ -419,7 +418,7 @@ const wchar_t* CXFA_FMLexer::Identifiers(CXFA_FMToken* t, const wchar_t* p) {
if (!IsValid(p)) {
t->m_wstring = CFX_WideStringC(pStart, (p - pStart));
- Error(kFMErrUnsupportedChar, ch);
+ m_LexerError = true;
return p;
}
@@ -427,7 +426,7 @@ const wchar_t* CXFA_FMLexer::Identifiers(CXFA_FMToken* t, const wchar_t* p) {
while (ch) {
if (!IsValid(p)) {
t->m_wstring = CFX_WideStringC(pStart, (p - pStart));
- Error(kFMErrUnsupportedChar, ch);
+ m_LexerError = true;
return p;
}
@@ -486,16 +485,3 @@ XFA_FM_TOKEN CXFA_FMLexer::IsKeyword(const CFX_WideStringC& str) {
} while (iStart <= iEnd);
return TOKidentifier;
}
-
-void CXFA_FMLexer::Error(const wchar_t* msg, ...) {
- m_pErrorInfo->linenum = m_uCurrentLine;
- va_list ap;
- va_start(ap, msg);
- m_pErrorInfo->message.FormatV(msg, ap);
- va_end(ap);
- ASSERT(!m_pErrorInfo->message.IsEmpty());
-}
-
-bool CXFA_FMLexer::HasError() const {
- return !m_pErrorInfo->message.IsEmpty();
-}
diff --git a/xfa/fxfa/fm2js/cxfa_fmlexer.h b/xfa/fxfa/fm2js/cxfa_fmlexer.h
index 4baa4a594f..f4f8a68d8c 100644
--- a/xfa/fxfa/fm2js/cxfa_fmlexer.h
+++ b/xfa/fxfa/fm2js/cxfa_fmlexer.h
@@ -11,7 +11,6 @@
#include <utility>
#include "core/fxcrt/fx_string.h"
-#include "xfa/fxfa/fm2js/cxfa_fmerrorinfo.h"
enum XFA_FM_TOKEN {
TOKand,
@@ -104,11 +103,11 @@ class CXFA_FMToken {
class CXFA_FMLexer {
public:
- CXFA_FMLexer(const CFX_WideStringC& wsFormcalc, CXFA_FMErrorInfo* pErrorInfo);
+ explicit CXFA_FMLexer(const CFX_WideStringC& wsFormcalc);
~CXFA_FMLexer();
CXFA_FMToken* NextToken();
- bool HasError() const;
+ bool HasError() const { return m_LexerError; }
void SetCurrentLine(uint32_t line) { m_uCurrentLine = line; }
void SetToken(std::unique_ptr<CXFA_FMToken> pToken) {
@@ -124,14 +123,13 @@ class CXFA_FMLexer {
const wchar_t* Identifiers(CXFA_FMToken* t, const wchar_t* p);
const wchar_t* Comment(const wchar_t* p);
XFA_FM_TOKEN IsKeyword(const CFX_WideStringC& p);
- void Error(const wchar_t* msg, ...);
std::unique_ptr<CXFA_FMToken> Scan();
const wchar_t* m_ptr;
const wchar_t* const m_end;
uint32_t m_uCurrentLine;
std::unique_ptr<CXFA_FMToken> m_pToken;
- CXFA_FMErrorInfo* m_pErrorInfo;
+ bool m_LexerError;
};
#endif // XFA_FXFA_FM2JS_CXFA_FMLEXER_H_
diff --git a/xfa/fxfa/fm2js/cxfa_fmlexer_unittest.cpp b/xfa/fxfa/fm2js/cxfa_fmlexer_unittest.cpp
index f47e985c8c..7ca12d2fad 100644
--- a/xfa/fxfa/fm2js/cxfa_fmlexer_unittest.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmlexer_unittest.cpp
@@ -11,13 +11,13 @@
#include "third_party/base/ptr_util.h"
TEST(CXFA_FMLexerTest, EmptyString) {
- CXFA_FMLexer lexer(L"", nullptr);
+ CXFA_FMLexer lexer(L"");
CXFA_FMToken* token = lexer.NextToken();
EXPECT_EQ(TOKeof, token->m_type);
}
TEST(CXFA_FMLexerTest, Numbers) {
- auto lexer = pdfium::MakeUnique<CXFA_FMLexer>(L"-12", nullptr);
+ auto lexer = pdfium::MakeUnique<CXFA_FMLexer>(L"-12");
CXFA_FMToken* token = lexer->NextToken();
// TODO(dsinclair): Should this return -12 instead of two tokens?
EXPECT_EQ(TOKminus, token->m_type);
@@ -26,34 +26,34 @@ TEST(CXFA_FMLexerTest, Numbers) {
token = lexer->NextToken();
EXPECT_EQ(TOKeof, token->m_type);
- lexer = pdfium::MakeUnique<CXFA_FMLexer>(L"1.5362", nullptr);
+ lexer = pdfium::MakeUnique<CXFA_FMLexer>(L"1.5362");
token = lexer->NextToken();
EXPECT_EQ(TOKnumber, token->m_type);
EXPECT_EQ(L"1.5362", token->m_wstring);
- lexer = pdfium::MakeUnique<CXFA_FMLexer>(L"0.875", nullptr);
+ lexer = pdfium::MakeUnique<CXFA_FMLexer>(L"0.875");
token = lexer->NextToken();
EXPECT_EQ(TOKnumber, token->m_type);
EXPECT_EQ(L"0.875", token->m_wstring);
- lexer = pdfium::MakeUnique<CXFA_FMLexer>(L"5.56e-2", nullptr);
+ lexer = pdfium::MakeUnique<CXFA_FMLexer>(L"5.56e-2");
token = lexer->NextToken();
EXPECT_EQ(TOKnumber, token->m_type);
EXPECT_EQ(L"5.56e-2", token->m_wstring);
- lexer = pdfium::MakeUnique<CXFA_FMLexer>(L"1.234E10", nullptr);
+ lexer = pdfium::MakeUnique<CXFA_FMLexer>(L"1.234E10");
token = lexer->NextToken();
EXPECT_EQ(TOKnumber, token->m_type);
EXPECT_EQ(L"1.234E10", token->m_wstring);
- lexer = pdfium::MakeUnique<CXFA_FMLexer>(L"123456789.012345678", nullptr);
+ lexer = pdfium::MakeUnique<CXFA_FMLexer>(L"123456789.012345678");
token = lexer->NextToken();
EXPECT_EQ(TOKnumber, token->m_type);
// TODO(dsinclair): This should round as per IEEE 64-bit values.
// EXPECT_EQ(L"123456789.01234567", token->m_wstring);
EXPECT_EQ(L"123456789.012345678", token->m_wstring);
- lexer = pdfium::MakeUnique<CXFA_FMLexer>(L"99999999999999999", nullptr);
+ lexer = pdfium::MakeUnique<CXFA_FMLexer>(L"99999999999999999");
token = lexer->NextToken();
EXPECT_EQ(TOKnumber, token->m_type);
// TODO(dsinclair): This is spec'd as rounding when > 16 significant digits
@@ -64,8 +64,8 @@ TEST(CXFA_FMLexerTest, Numbers) {
// The quotes are stripped in CXFA_FMStringExpression::ToJavaScript.
TEST(CXFA_FMLexerTest, Strings) {
- auto lexer = pdfium::MakeUnique<CXFA_FMLexer>(
- L"\"The cat jumped over the fence.\"", nullptr);
+ auto lexer =
+ pdfium::MakeUnique<CXFA_FMLexer>(L"\"The cat jumped over the fence.\"");
CXFA_FMToken* token = lexer->NextToken();
EXPECT_EQ(TOKstring, token->m_type);
EXPECT_EQ(L"\"The cat jumped over the fence.\"", token->m_wstring);
@@ -73,21 +73,20 @@ TEST(CXFA_FMLexerTest, Strings) {
token = lexer->NextToken();
EXPECT_EQ(TOKeof, token->m_type);
- lexer = pdfium::MakeUnique<CXFA_FMLexer>(L"\"\"", nullptr);
+ lexer = pdfium::MakeUnique<CXFA_FMLexer>(L"\"\"");
token = lexer->NextToken();
EXPECT_EQ(TOKstring, token->m_type);
EXPECT_EQ(L"\"\"", token->m_wstring);
lexer = pdfium::MakeUnique<CXFA_FMLexer>(
- L"\"The message reads: \"\"Warning: Insufficient Memory\"\"\"", nullptr);
+ L"\"The message reads: \"\"Warning: Insufficient Memory\"\"\"");
token = lexer->NextToken();
EXPECT_EQ(TOKstring, token->m_type);
EXPECT_EQ(L"\"The message reads: \"\"Warning: Insufficient Memory\"\"\"",
token->m_wstring);
lexer = pdfium::MakeUnique<CXFA_FMLexer>(
- L"\"\\u0047\\u006f\\u0066\\u0069\\u0073\\u0068\\u0021\\u000d\\u000a\"",
- nullptr);
+ L"\"\\u0047\\u006f\\u0066\\u0069\\u0073\\u0068\\u0021\\u000d\\u000a\"");
token = lexer->NextToken();
EXPECT_EQ(TOKstring, token->m_type);
EXPECT_EQ(
@@ -161,22 +160,22 @@ TEST(CXFA_FMLexerTest, OperatorsAndKeywords) {
{L".*", TOKdotstar}};
for (size_t i = 0; i < FX_ArraySize(op); ++i) {
- auto lexer = pdfium::MakeUnique<CXFA_FMLexer>(op[i].op, nullptr);
+ auto lexer = pdfium::MakeUnique<CXFA_FMLexer>(op[i].op);
CXFA_FMToken* token = lexer->NextToken();
EXPECT_EQ(op[i].token, token->m_type);
}
}
TEST(CXFA_FMLexerTest, Comments) {
- auto lexer = pdfium::MakeUnique<CXFA_FMLexer>(L"// Empty.", nullptr);
+ auto lexer = pdfium::MakeUnique<CXFA_FMLexer>(L"// Empty.");
CXFA_FMToken* token = lexer->NextToken();
EXPECT_EQ(TOKeof, token->m_type);
- lexer = pdfium::MakeUnique<CXFA_FMLexer>(L"//", nullptr);
+ lexer = pdfium::MakeUnique<CXFA_FMLexer>(L"//");
token = lexer->NextToken();
EXPECT_EQ(TOKeof, token->m_type);
- lexer = pdfium::MakeUnique<CXFA_FMLexer>(L"123 // Empty.\n\"str\"", nullptr);
+ lexer = pdfium::MakeUnique<CXFA_FMLexer>(L"123 // Empty.\n\"str\"");
token = lexer->NextToken();
EXPECT_EQ(TOKnumber, token->m_type);
EXPECT_EQ(L"123", token->m_wstring);
@@ -188,15 +187,15 @@ TEST(CXFA_FMLexerTest, Comments) {
token = lexer->NextToken();
EXPECT_EQ(TOKeof, token->m_type);
- lexer = pdfium::MakeUnique<CXFA_FMLexer>(L";", nullptr);
+ lexer = pdfium::MakeUnique<CXFA_FMLexer>(L";");
token = lexer->NextToken();
EXPECT_EQ(TOKeof, token->m_type);
- lexer = pdfium::MakeUnique<CXFA_FMLexer>(L"; Empty.", nullptr);
+ lexer = pdfium::MakeUnique<CXFA_FMLexer>(L"; Empty.");
token = lexer->NextToken();
EXPECT_EQ(TOKeof, token->m_type);
- lexer = pdfium::MakeUnique<CXFA_FMLexer>(L"123 ;Empty.\n\"str\"", nullptr);
+ lexer = pdfium::MakeUnique<CXFA_FMLexer>(L"123 ;Empty.\n\"str\"");
token = lexer->NextToken();
EXPECT_EQ(TOKnumber, token->m_type);
EXPECT_EQ(L"123", token->m_wstring);
@@ -213,7 +212,7 @@ TEST(CXFA_FMLexerTest, Identifiers) {
std::vector<const wchar_t*> identifiers = {
L"a", L"an_identifier", L"_ident", L"$ident", L"!ident", L"GetAddr"};
for (const auto* ident : identifiers) {
- auto lexer = pdfium::MakeUnique<CXFA_FMLexer>(ident, nullptr);
+ auto lexer = pdfium::MakeUnique<CXFA_FMLexer>(ident);
CXFA_FMToken* token = lexer->NextToken();
EXPECT_EQ(TOKidentifier, token->m_type);
EXPECT_EQ(ident, token->m_wstring);
@@ -221,11 +220,11 @@ TEST(CXFA_FMLexerTest, Identifiers) {
}
TEST(CXFA_FMLexerTest, Whitespace) {
- auto lexer = pdfium::MakeUnique<CXFA_FMLexer>(L" \t\xc\x9\xb", nullptr);
+ auto lexer = pdfium::MakeUnique<CXFA_FMLexer>(L" \t\xc\x9\xb");
CXFA_FMToken* token = lexer->NextToken();
EXPECT_EQ(TOKeof, token->m_type);
- lexer = pdfium::MakeUnique<CXFA_FMLexer>(L"123 \t\xc\x9\xb 456", nullptr);
+ lexer = pdfium::MakeUnique<CXFA_FMLexer>(L"123 \t\xc\x9\xb 456");
token = lexer->NextToken();
EXPECT_EQ(TOKnumber, token->m_type);
EXPECT_EQ(L"123", token->m_wstring);
diff --git a/xfa/fxfa/fm2js/cxfa_fmparse.cpp b/xfa/fxfa/fm2js/cxfa_fmparse.cpp
index 6e80a40d0c..50e60d3269 100644
--- a/xfa/fxfa/fm2js/cxfa_fmparse.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmparse.cpp
@@ -18,10 +18,9 @@ const int kMaxAssignmentChainLength = 12;
} // namespace
-CXFA_FMParse::CXFA_FMParse(const CFX_WideStringC& wsFormcalc,
- CXFA_FMErrorInfo* pErrorInfo)
- : m_pToken(nullptr), m_pErrorInfo(pErrorInfo) {
- m_lexer = pdfium::MakeUnique<CXFA_FMLexer>(wsFormcalc, m_pErrorInfo);
+CXFA_FMParse::CXFA_FMParse(const CFX_WideStringC& wsFormcalc)
+ : m_pToken(nullptr), m_ParserError(false) {
+ m_lexer = pdfium::MakeUnique<CXFA_FMLexer>(wsFormcalc);
}
CXFA_FMParse::~CXFA_FMParse() {}
@@ -43,30 +42,18 @@ std::unique_ptr<CXFA_FMFunctionDefinition> CXFA_FMParse::Parse() {
void CXFA_FMParse::NextToken() {
m_pToken = m_lexer->NextToken();
while (m_pToken->m_type == TOKreserver) {
- if (m_lexer->HasError())
+ if (HasError())
break;
-
m_pToken = m_lexer->NextToken();
}
}
void CXFA_FMParse::Check(XFA_FM_TOKEN op) {
- if (m_pToken->m_type != op) {
- Error(kFMErrExpectedToken, XFA_FM_KeywordToString(op),
- m_pToken->m_wstring.c_str());
- }
+ if (m_pToken->m_type != op)
+ m_ParserError = true;
NextToken();
}
-void CXFA_FMParse::Error(const wchar_t* msg, ...) {
- m_pErrorInfo->linenum = m_pToken->m_uLinenum;
- va_list ap;
- va_start(ap, msg);
- m_pErrorInfo->message.FormatV(msg, ap);
- va_end(ap);
- ASSERT(!m_pErrorInfo->message.IsEmpty());
-}
-
std::vector<std::unique_ptr<CXFA_FMExpression>>
CXFA_FMParse::ParseTopExpression() {
std::unique_ptr<CXFA_FMExpression> expr;
@@ -93,7 +80,7 @@ std::unique_ptr<CXFA_FMExpression> CXFA_FMParse::ParseFunction() {
uint32_t line = m_pToken->m_uLinenum;
NextToken();
if (m_pToken->m_type != TOKidentifier) {
- Error(kFMErrExpectedIdentifier, m_pToken->m_wstring.c_str());
+ m_ParserError = true;
} else {
ident = m_pToken->m_wstring;
NextToken();
@@ -115,7 +102,7 @@ std::unique_ptr<CXFA_FMExpression> CXFA_FMParse::ParseFunction() {
else
Check(TOKrparen);
} else {
- Error(kFMErrExpectedIdentifier, m_pToken->m_wstring.c_str());
+ m_ParserError = true;
NextToken();
}
break;
@@ -176,7 +163,7 @@ std::unique_ptr<CXFA_FMExpression> CXFA_FMParse::ParseExpression() {
NextToken();
break;
default:
- Error(kFMErrUnexpectedExpression, m_pToken->m_wstring.c_str());
+ m_ParserError = true;
NextToken();
break;
}
@@ -188,7 +175,7 @@ std::unique_ptr<CXFA_FMExpression> CXFA_FMParse::ParseVarExpression() {
uint32_t line = m_pToken->m_uLinenum;
NextToken();
if (m_pToken->m_type != TOKidentifier) {
- Error(kFMErrExpectedIdentifier, m_pToken->m_wstring.c_str());
+ m_ParserError = true;
} else {
ident = m_pToken->m_wstring;
NextToken();
@@ -212,8 +199,8 @@ std::unique_ptr<CXFA_FMSimpleExpression> CXFA_FMParse::ParseSimpleExpression() {
NextToken();
std::unique_ptr<CXFA_FMSimpleExpression> pExp2 = ParseLogicalOrExpression();
if (level++ == kMaxAssignmentChainLength)
- Error(kFMErrLongAssignmentChain);
- if (m_pErrorInfo->message.IsEmpty()) {
+ m_ParserError = true;
+ if (!HasError()) {
pExp1 = pdfium::MakeUnique<CXFA_FMAssignExpression>(
line, TOKassign, std::move(pExp1), std::move(pExp2));
} else {
@@ -243,7 +230,7 @@ CXFA_FMParse::ParseLogicalOrExpression() {
NextToken();
std::unique_ptr<CXFA_FMSimpleExpression> e2(
ParseLogicalAndExpression());
- if (m_pErrorInfo->message.IsEmpty()) {
+ if (!HasError()) {
e1 = pdfium::MakeUnique<CXFA_FMLogicalOrExpression>(
line, TOKor, std::move(e1), std::move(e2));
} else {
@@ -269,7 +256,7 @@ CXFA_FMParse::ParseLogicalAndExpression() {
case TOKksand: {
NextToken();
std::unique_ptr<CXFA_FMSimpleExpression> e2 = ParseEqualityExpression();
- if (m_pErrorInfo->message.IsEmpty()) {
+ if (!HasError()) {
e1 = pdfium::MakeUnique<CXFA_FMLogicalAndExpression>(
line, TOKand, std::move(e1), std::move(e2));
} else {
@@ -296,7 +283,7 @@ CXFA_FMParse::ParseEqualityExpression() {
case TOKkseq:
NextToken();
e2 = ParseRelationalExpression();
- if (m_pErrorInfo->message.IsEmpty()) {
+ if (!HasError()) {
e1 = pdfium::MakeUnique<CXFA_FMEqualityExpression>(
line, TOKeq, std::move(e1), std::move(e2));
} else {
@@ -307,7 +294,7 @@ CXFA_FMParse::ParseEqualityExpression() {
case TOKksne:
NextToken();
e2 = ParseRelationalExpression();
- if (m_pErrorInfo->message.IsEmpty()) {
+ if (!HasError()) {
e1 = pdfium::MakeUnique<CXFA_FMEqualityExpression>(
line, TOKne, std::move(e1), std::move(e2));
} else {
@@ -333,7 +320,7 @@ CXFA_FMParse::ParseRelationalExpression() {
case TOKkslt:
NextToken();
e2 = ParseAddtiveExpression();
- if (m_pErrorInfo->message.IsEmpty()) {
+ if (!HasError()) {
e1 = pdfium::MakeUnique<CXFA_FMRelationalExpression>(
line, TOKlt, std::move(e1), std::move(e2));
} else {
@@ -344,7 +331,7 @@ CXFA_FMParse::ParseRelationalExpression() {
case TOKksgt:
NextToken();
e2 = ParseAddtiveExpression();
- if (m_pErrorInfo->message.IsEmpty()) {
+ if (!HasError()) {
e1 = pdfium::MakeUnique<CXFA_FMRelationalExpression>(
line, TOKgt, std::move(e1), std::move(e2));
} else {
@@ -355,7 +342,7 @@ CXFA_FMParse::ParseRelationalExpression() {
case TOKksle:
NextToken();
e2 = ParseAddtiveExpression();
- if (m_pErrorInfo->message.IsEmpty()) {
+ if (!HasError()) {
e1 = pdfium::MakeUnique<CXFA_FMRelationalExpression>(
line, TOKle, std::move(e1), std::move(e2));
} else {
@@ -366,7 +353,7 @@ CXFA_FMParse::ParseRelationalExpression() {
case TOKksge:
NextToken();
e2 = ParseAddtiveExpression();
- if (m_pErrorInfo->message.IsEmpty()) {
+ if (!HasError()) {
e1 = pdfium::MakeUnique<CXFA_FMRelationalExpression>(
line, TOKge, std::move(e1), std::move(e2));
} else {
@@ -391,7 +378,7 @@ CXFA_FMParse::ParseAddtiveExpression() {
case TOKplus:
NextToken();
e2 = ParseMultiplicativeExpression();
- if (m_pErrorInfo->message.IsEmpty()) {
+ if (!HasError()) {
e1 = pdfium::MakeUnique<CXFA_FMAdditiveExpression>(
line, TOKplus, std::move(e1), std::move(e2));
} else {
@@ -401,7 +388,7 @@ CXFA_FMParse::ParseAddtiveExpression() {
case TOKminus:
NextToken();
e2 = ParseMultiplicativeExpression();
- if (m_pErrorInfo->message.IsEmpty()) {
+ if (!HasError()) {
e1 = pdfium::MakeUnique<CXFA_FMAdditiveExpression>(
line, TOKminus, std::move(e1), std::move(e2));
} else {
@@ -426,7 +413,7 @@ CXFA_FMParse::ParseMultiplicativeExpression() {
case TOKmul:
NextToken();
e2 = ParseUnaryExpression();
- if (m_pErrorInfo->message.IsEmpty()) {
+ if (!HasError()) {
e1 = pdfium::MakeUnique<CXFA_FMMultiplicativeExpression>(
line, TOKmul, std::move(e1), std::move(e2));
} else {
@@ -436,7 +423,7 @@ CXFA_FMParse::ParseMultiplicativeExpression() {
case TOKdiv:
NextToken();
e2 = ParseUnaryExpression();
- if (m_pErrorInfo->message.IsEmpty()) {
+ if (!HasError()) {
e1 = pdfium::MakeUnique<CXFA_FMMultiplicativeExpression>(
line, TOKdiv, std::move(e1), std::move(e2));
} else {
@@ -458,7 +445,7 @@ std::unique_ptr<CXFA_FMSimpleExpression> CXFA_FMParse::ParseUnaryExpression() {
case TOKplus:
NextToken();
expr = ParseUnaryExpression();
- if (m_pErrorInfo->message.IsEmpty())
+ if (!HasError())
expr = pdfium::MakeUnique<CXFA_FMPosExpression>(line, std::move(expr));
else
expr.reset();
@@ -466,7 +453,7 @@ std::unique_ptr<CXFA_FMSimpleExpression> CXFA_FMParse::ParseUnaryExpression() {
case TOKminus:
NextToken();
expr = ParseUnaryExpression();
- if (m_pErrorInfo->message.IsEmpty())
+ if (!HasError())
expr = pdfium::MakeUnique<CXFA_FMNegExpression>(line, std::move(expr));
else
expr.reset();
@@ -474,7 +461,7 @@ std::unique_ptr<CXFA_FMSimpleExpression> CXFA_FMParse::ParseUnaryExpression() {
case TOKksnot:
NextToken();
expr = ParseUnaryExpression();
- if (m_pErrorInfo->message.IsEmpty())
+ if (!HasError())
expr = pdfium::MakeUnique<CXFA_FMNotExpression>(line, std::move(expr));
else
expr.reset();
@@ -530,7 +517,7 @@ CXFA_FMParse::ParsePrimaryExpression() {
expr = ParseParenExpression();
break;
default:
- Error(kFMErrUnexpectedExpression, m_pToken->m_wstring.c_str());
+ m_ParserError = true;
NextToken();
break;
}
@@ -560,12 +547,10 @@ std::unique_ptr<CXFA_FMSimpleExpression> CXFA_FMParse::ParsePostExpression(
break;
}
}
- if (m_pToken->m_type != TOKrparen) {
- Error(kFMErrExpectedToken, XFA_FM_KeywordToString(TOKrparen),
- m_pToken->m_wstring.c_str());
- }
+ if (m_pToken->m_type != TOKrparen)
+ m_ParserError = true;
}
- if (m_pErrorInfo->message.IsEmpty()) {
+ if (!HasError()) {
expr = pdfium::MakeUnique<CXFA_FMCallExpression>(
line, std::move(expr), std::move(expressions), false);
NextToken();
@@ -606,12 +591,10 @@ std::unique_ptr<CXFA_FMSimpleExpression> CXFA_FMParse::ParsePostExpression(
break;
}
}
- if (m_pToken->m_type != TOKrparen) {
- Error(kFMErrExpectedToken, XFA_FM_KeywordToString(TOKrparen),
- m_pToken->m_wstring.c_str());
- }
+ if (m_pToken->m_type != TOKrparen)
+ m_ParserError = true;
}
- if (m_pErrorInfo->message.IsEmpty()) {
+ if (!HasError()) {
std::unique_ptr<CXFA_FMSimpleExpression> pIdentifier =
pdfium::MakeUnique<CXFA_FMIdentifierExpression>(tempLine,
tempStr);
@@ -650,7 +633,7 @@ std::unique_ptr<CXFA_FMSimpleExpression> CXFA_FMParse::ParsePostExpression(
continue;
}
} else {
- Error(kFMErrExpectedIdentifier, m_pToken->m_wstring.c_str());
+ m_ParserError = true;
return expr;
}
break;
@@ -676,14 +659,14 @@ std::unique_ptr<CXFA_FMSimpleExpression> CXFA_FMParse::ParsePostExpression(
continue;
}
} else {
- Error(kFMErrExpectedIdentifier, m_pToken->m_wstring.c_str());
+ m_ParserError = true;
return expr;
}
break;
case TOKdotscream: {
NextToken();
if (m_pToken->m_type != TOKidentifier) {
- Error(kFMErrExpectedIdentifier, m_pToken->m_wstring.c_str());
+ m_ParserError = true;
return expr;
}
CFX_WideStringC tempStr = m_pToken->m_wstring;
@@ -732,8 +715,7 @@ std::unique_ptr<CXFA_FMSimpleExpression> CXFA_FMParse::ParseIndexExpression() {
std::move(s), true);
NextToken();
if (m_pToken->m_type != TOKrbracket) {
- Error(kFMErrExpectedToken, XFA_FM_KeywordToString(TOKrparen),
- m_pToken->m_wstring.c_str());
+ m_ParserError = true;
pExp.reset();
}
return pExp;
@@ -747,8 +729,7 @@ std::unique_ptr<CXFA_FMSimpleExpression> CXFA_FMParse::ParseIndexExpression() {
}
s = ParseSimpleExpression();
if (m_pToken->m_type != TOKrbracket) {
- Error(kFMErrExpectedToken, XFA_FM_KeywordToString(TOKrparen),
- m_pToken->m_wstring.c_str());
+ m_ParserError = true;
} else {
pExp = pdfium::MakeUnique<CXFA_FMIndexExpression>(line, accessorIndex,
std::move(s), false);
@@ -760,7 +741,7 @@ std::unique_ptr<CXFA_FMSimpleExpression> CXFA_FMParse::ParseParenExpression() {
Check(TOKlparen);
if (m_pToken->m_type == TOKrparen) {
- Error(kFMErrExpectedNonEmptyExpression);
+ m_ParserError = true;
NextToken();
return nullptr;
}
@@ -773,8 +754,8 @@ std::unique_ptr<CXFA_FMSimpleExpression> CXFA_FMParse::ParseParenExpression() {
NextToken();
std::unique_ptr<CXFA_FMSimpleExpression> pExp2 = ParseLogicalOrExpression();
if (level++ == kMaxAssignmentChainLength)
- Error(kFMErrLongAssignmentChain);
- if (m_pErrorInfo->message.IsEmpty()) {
+ m_ParserError = true;
+ if (!HasError()) {
pExp1 = pdfium::MakeUnique<CXFA_FMAssignExpression>(
line, TOKassign, std::move(pExp1), std::move(pExp2));
} else {
@@ -818,7 +799,7 @@ std::unique_ptr<CXFA_FMExpression> CXFA_FMParse::ParseBlockExpression() {
break;
}
std::unique_ptr<CXFA_FMBlockExpression> pExp;
- if (m_pErrorInfo->message.IsEmpty()) {
+ if (!HasError()) {
pExp = pdfium::MakeUnique<CXFA_FMBlockExpression>(line,
std::move(expressions));
}
@@ -869,12 +850,12 @@ std::unique_ptr<CXFA_FMExpression> CXFA_FMParse::ParseIfExpression() {
Check(TOKendif);
break;
default:
- Error(kFMErrExpectedEndIf, m_pToken->m_wstring.c_str());
+ m_ParserError = true;
NextToken();
break;
}
std::unique_ptr<CXFA_FMIfExpression> pExp;
- if (m_pErrorInfo->message.IsEmpty()) {
+ if (!HasError()) {
pExp = pdfium::MakeUnique<CXFA_FMIfExpression>(line, std::move(pExpression),
std::move(pIfExpression),
std::move(pElseExpression));
@@ -890,7 +871,7 @@ std::unique_ptr<CXFA_FMExpression> CXFA_FMParse::ParseWhileExpression() {
std::unique_ptr<CXFA_FMExpression> pExpression = ParseBlockExpression();
Check(TOKendwhile);
std::unique_ptr<CXFA_FMExpression> expr;
- if (m_pErrorInfo->message.IsEmpty()) {
+ if (!HasError()) {
expr = pdfium::MakeUnique<CXFA_FMWhileExpression>(
line, std::move(pCondition), std::move(pExpression));
}
@@ -905,7 +886,7 @@ CXFA_FMParse::ParseSubassignmentInForExpression() {
expr = ParseSimpleExpression();
break;
default:
- Error(kFMErrUnexpectedExpression, m_pToken->m_wstring.c_str());
+ m_ParserError = true;
NextToken();
break;
}
@@ -916,10 +897,9 @@ std::unique_ptr<CXFA_FMExpression> CXFA_FMParse::ParseForExpression() {
CFX_WideStringC wsVariant;
uint32_t line = m_pToken->m_uLinenum;
NextToken();
- if (m_pToken->m_type != TOKidentifier) {
- Error(kFMErrExpectedToken, XFA_FM_KeywordToString(m_pToken->m_type),
- m_pToken->m_wstring.c_str());
- }
+ if (m_pToken->m_type != TOKidentifier)
+ m_ParserError = true;
+
wsVariant = m_pToken->m_wstring;
NextToken();
std::unique_ptr<CXFA_FMSimpleExpression> pAssignment;
@@ -927,17 +907,17 @@ std::unique_ptr<CXFA_FMExpression> CXFA_FMParse::ParseForExpression() {
NextToken();
pAssignment = ParseSimpleExpression();
} else {
- Error(kFMErrExpectedToken, XFA_FM_KeywordToString(m_pToken->m_type),
- m_pToken->m_wstring.c_str());
+ m_ParserError = true;
}
+
int32_t iDirection = 0;
- if (m_pToken->m_type == TOKupto) {
+ if (m_pToken->m_type == TOKupto)
iDirection = 1;
- } else if (m_pToken->m_type == TOKdownto) {
+ else if (m_pToken->m_type == TOKdownto)
iDirection = -1;
- } else {
- Error(kFMErrExpectedToken, L"upto or downto", m_pToken->m_wstring.c_str());
- }
+ else
+ m_ParserError = true;
+
NextToken();
std::unique_ptr<CXFA_FMSimpleExpression> pAccessor = ParseSimpleExpression();
std::unique_ptr<CXFA_FMSimpleExpression> pStep;
@@ -949,7 +929,7 @@ std::unique_ptr<CXFA_FMExpression> CXFA_FMParse::ParseForExpression() {
std::unique_ptr<CXFA_FMExpression> pList = ParseBlockExpression();
Check(TOKendfor);
std::unique_ptr<CXFA_FMExpression> expr;
- if (m_pErrorInfo->message.IsEmpty()) {
+ if (!HasError()) {
expr = pdfium::MakeUnique<CXFA_FMForExpression>(
line, wsVariant, std::move(pAssignment), std::move(pAccessor),
iDirection, std::move(pStep), std::move(pList));
@@ -964,16 +944,15 @@ std::unique_ptr<CXFA_FMExpression> CXFA_FMParse::ParseForeachExpression() {
std::unique_ptr<CXFA_FMExpression> pList;
uint32_t line = m_pToken->m_uLinenum;
NextToken();
- if (m_pToken->m_type != TOKidentifier) {
- Error(kFMErrExpectedToken, XFA_FM_KeywordToString(m_pToken->m_type),
- m_pToken->m_wstring.c_str());
- }
+ if (m_pToken->m_type != TOKidentifier)
+ m_ParserError = true;
+
wsIdentifier = m_pToken->m_wstring;
NextToken();
Check(TOKin);
Check(TOKlparen);
if (m_pToken->m_type == TOKrparen) {
- Error(kFMErrUnexpectedExpression, m_pToken->m_wstring.c_str());
+ m_ParserError = true;
NextToken();
} else {
while (m_pToken->m_type != TOKrparen) {
@@ -989,7 +968,7 @@ std::unique_ptr<CXFA_FMExpression> CXFA_FMParse::ParseForeachExpression() {
Check(TOKdo);
pList = ParseBlockExpression();
Check(TOKendfor);
- if (m_pErrorInfo->message.IsEmpty()) {
+ if (!HasError()) {
expr = pdfium::MakeUnique<CXFA_FMForeachExpression>(
line, wsIdentifier, std::move(pAccessors), std::move(pList));
}
@@ -1008,5 +987,5 @@ std::unique_ptr<CXFA_FMExpression> CXFA_FMParse::ParseDoExpression() {
}
bool CXFA_FMParse::HasError() const {
- return !m_pErrorInfo->message.IsEmpty();
+ return m_ParserError || m_lexer->HasError();
}
diff --git a/xfa/fxfa/fm2js/cxfa_fmparse.h b/xfa/fxfa/fm2js/cxfa_fmparse.h
index 625145e7a2..0f7109135d 100644
--- a/xfa/fxfa/fm2js/cxfa_fmparse.h
+++ b/xfa/fxfa/fm2js/cxfa_fmparse.h
@@ -15,16 +15,16 @@
class CXFA_FMParse {
public:
- CXFA_FMParse(const CFX_WideStringC& wsFormcalc, CXFA_FMErrorInfo* pErrorInfo);
+ explicit CXFA_FMParse(const CFX_WideStringC& wsFormcalc);
~CXFA_FMParse();
std::unique_ptr<CXFA_FMFunctionDefinition> Parse();
+ bool HasError() const;
private:
void NextToken();
void Check(XFA_FM_TOKEN op);
- void Error(const wchar_t* msg, ...);
- bool HasError() const;
+
std::vector<std::unique_ptr<CXFA_FMExpression>> ParseTopExpression();
std::unique_ptr<CXFA_FMExpression> ParseFunction();
std::unique_ptr<CXFA_FMExpression> ParseExpression();
@@ -53,7 +53,7 @@ class CXFA_FMParse {
std::unique_ptr<CXFA_FMLexer> m_lexer;
CXFA_FMToken* m_pToken;
- CXFA_FMErrorInfo* const m_pErrorInfo;
+ bool m_ParserError;
};
#endif // XFA_FXFA_FM2JS_CXFA_FMPARSE_H_
diff --git a/xfa/fxfa/fm2js/cxfa_fmparse_unittest.cpp b/xfa/fxfa/fm2js/cxfa_fmparse_unittest.cpp
index c98cd227ce..9e6972b356 100644
--- a/xfa/fxfa/fm2js/cxfa_fmparse_unittest.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmparse_unittest.cpp
@@ -11,11 +11,10 @@
#include "third_party/base/ptr_util.h"
TEST(CXFA_FMParseTest, Empty) {
- CXFA_FMErrorInfo errorInfo;
- auto parser = pdfium::MakeUnique<CXFA_FMParse>(L"", &errorInfo);
+ auto parser = pdfium::MakeUnique<CXFA_FMParse>(L"");
std::unique_ptr<CXFA_FMFunctionDefinition> ast = parser->Parse();
ASSERT(ast != nullptr);
- EXPECT_TRUE(errorInfo.message.IsEmpty());
+ EXPECT_FALSE(parser->HasError());
CFX_WideTextBuf buf;
EXPECT_TRUE(ast->ToJavaScript(buf));
@@ -24,13 +23,12 @@ TEST(CXFA_FMParseTest, Empty) {
}
TEST(CXFA_FMParseTest, CommentOnlyIsError) {
- CXFA_FMErrorInfo errorInfo;
- auto parser = pdfium::MakeUnique<CXFA_FMParse>(L"; Just comment", &errorInfo);
+ auto parser = pdfium::MakeUnique<CXFA_FMParse>(L"; Just comment");
std::unique_ptr<CXFA_FMFunctionDefinition> ast = parser->Parse();
ASSERT(ast != nullptr);
// TODO(dsinclair): This isn't allowed per the spec.
- EXPECT_TRUE(errorInfo.message.IsEmpty());
- // EXPECT_FALSE(errorInfo.message.IsEmpty());
+ EXPECT_FALSE(parser->HasError());
+ // EXPECT_TRUE(parser->HasError());
CFX_WideTextBuf buf;
EXPECT_TRUE(ast->ToJavaScript(buf));
@@ -45,12 +43,10 @@ TEST(CXFA_FMParseTest, CommentThenValue) {
L"return pfm_rt.get_val(pfm_ret);\n"
L"}\n).call(this);\n";
- CXFA_FMErrorInfo errorInfo;
- auto parser =
- pdfium::MakeUnique<CXFA_FMParse>(L"; Just comment\n12", &errorInfo);
+ auto parser = pdfium::MakeUnique<CXFA_FMParse>(L"; Just comment\n12");
std::unique_ptr<CXFA_FMFunctionDefinition> ast = parser->Parse();
ASSERT(ast != nullptr);
- EXPECT_TRUE(errorInfo.message.IsEmpty());
+ EXPECT_FALSE(parser->HasError());
CFX_WideTextBuf buf;
EXPECT_TRUE(ast->ToJavaScript(buf));
@@ -101,11 +97,10 @@ TEST(CXFA_FMParseTest, Parse) {
L"return pfm_rt.get_val(pfm_ret);\n"
L"}\n).call(this);\n";
- CXFA_FMErrorInfo errorInfo;
- auto parser = pdfium::MakeUnique<CXFA_FMParse>(input, &errorInfo);
+ auto parser = pdfium::MakeUnique<CXFA_FMParse>(input);
std::unique_ptr<CXFA_FMFunctionDefinition> ast = parser->Parse();
ASSERT(ast != nullptr);
- EXPECT_TRUE(errorInfo.message.IsEmpty());
+ EXPECT_FALSE(parser->HasError());
CFX_WideTextBuf buf;
EXPECT_TRUE(ast->ToJavaScript(buf));