summaryrefslogtreecommitdiff
path: root/xfa/fxfa/fm2js/cxfa_fmparse.h
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2017-07-27 14:24:02 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-07-27 18:38:09 +0000
commit7314af7d04d3fd4f29fff1f0da648944183bd0d0 (patch)
tree4048c996e6c1db9d1eb31d22cb91c46ede2e8e70 /xfa/fxfa/fm2js/cxfa_fmparse.h
parent495d89ff20806b6acdf564f3865b1fb974ccf44a (diff)
downloadpdfium-7314af7d04d3fd4f29fff1f0da648944183bd0d0.tar.xz
Rewrite FMLexer to use nullptr for errors
This CL rewrites how FMLexer returns errors, instead of having a flag that gets flipped and needs to be checked, it now returns nullptr for NextToken() when an error occurs. The Lexer's behaviour has also been changed to only return nullptr once an error has occurred, instead of advancing the lexing on further calls. FMParse now checks the returned value from the lexer instead of testing the error flag on the parser object. For any operation that might cause the error state of the parser to change, i.e. consuming a token, an error check has been added. In the event this check fails the related function returns nullptr. This will cause the parse to short circuit and exit. BUG=pdfium:814 Change-Id: I669012c4732c18d13009be7cd7bf1ae682950904 Reviewed-on: https://pdfium-review.googlesource.com/8950 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: (OOO Jul 28 - Aug 8) dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa/fxfa/fm2js/cxfa_fmparse.h')
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmparse.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/xfa/fxfa/fm2js/cxfa_fmparse.h b/xfa/fxfa/fm2js/cxfa_fmparse.h
index 0f7109135d..7377cc75d7 100644
--- a/xfa/fxfa/fm2js/cxfa_fmparse.h
+++ b/xfa/fxfa/fm2js/cxfa_fmparse.h
@@ -22,8 +22,8 @@ class CXFA_FMParse {
bool HasError() const;
private:
- void NextToken();
- void Check(XFA_FM_TOKEN op);
+ bool NextToken();
+ bool CheckThenNext(XFA_FM_TOKEN op);
std::vector<std::unique_ptr<CXFA_FMExpression>> ParseTopExpression();
std::unique_ptr<CXFA_FMExpression> ParseFunction();
@@ -52,8 +52,8 @@ class CXFA_FMParse {
std::unique_ptr<CXFA_FMSimpleExpression> ParseIndexExpression();
std::unique_ptr<CXFA_FMLexer> m_lexer;
- CXFA_FMToken* m_pToken;
- bool m_ParserError;
+ std::unique_ptr<CXFA_FMToken> m_token;
+ bool m_error;
};
#endif // XFA_FXFA_FM2JS_CXFA_FMPARSE_H_