summaryrefslogtreecommitdiff
path: root/xfa/fxfa/fm2js/cxfa_fmlexer.h
diff options
context:
space:
mode:
authordan sinclair <dsinclair@chromium.org>2018-02-19 16:44:22 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-02-19 16:44:22 +0000
commitc8785f736df57d7d20649d803818a30eb55b2ee8 (patch)
tree3eb05bb37167f7baaa74bfaaae9a1584c24ef322 /xfa/fxfa/fm2js/cxfa_fmlexer.h
parent916b4b05ce7b4dd5a254a72a1d98051655627dbc (diff)
downloadpdfium-c8785f736df57d7d20649d803818a30eb55b2ee8.tar.xz
Simplify CXFA_FMToken creation
This CL converts the CXFA_FMToken usages into an object instead of a pointer. A copy constructor has been added. The line number was removed from the token and is retrieved from the lexer where needed. Change-Id: I94c632653e9bf1439d2ddf374a816ae0d10b5b67 Reviewed-on: https://pdfium-review.googlesource.com/27192 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'xfa/fxfa/fm2js/cxfa_fmlexer.h')
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmlexer.h19
1 files changed, 8 insertions, 11 deletions
diff --git a/xfa/fxfa/fm2js/cxfa_fmlexer.h b/xfa/fxfa/fm2js/cxfa_fmlexer.h
index c94f2a901f..eb9e45e180 100644
--- a/xfa/fxfa/fm2js/cxfa_fmlexer.h
+++ b/xfa/fxfa/fm2js/cxfa_fmlexer.h
@@ -91,7 +91,8 @@ struct XFA_FMKeyword {
class CXFA_FMToken {
public:
CXFA_FMToken();
- explicit CXFA_FMToken(uint32_t line_num);
+ explicit CXFA_FMToken(XFA_FM_TOKEN token);
+ CXFA_FMToken(const CXFA_FMToken&);
~CXFA_FMToken();
#ifndef NDEBUG
@@ -100,7 +101,6 @@ class CXFA_FMToken {
WideStringView m_string;
XFA_FM_TOKEN m_type;
- uint32_t m_line_num;
};
class CXFA_FMLexer {
@@ -108,27 +108,24 @@ class CXFA_FMLexer {
explicit CXFA_FMLexer(const WideStringView& wsFormcalc);
~CXFA_FMLexer();
- std::unique_ptr<CXFA_FMToken> NextToken();
+ CXFA_FMToken NextToken();
+ uint32_t GetCurrentLine() const { return m_current_line; }
void SetCurrentLine(uint32_t line) { m_current_line = line; }
const wchar_t* GetPos() { return m_cursor; }
void SetPos(const wchar_t* pos) { m_cursor = pos; }
private:
- void AdvanceForNumber();
- void AdvanceForString();
- void AdvanceForIdentifier();
+ CXFA_FMToken AdvanceForNumber();
+ CXFA_FMToken AdvanceForString();
+ CXFA_FMToken AdvanceForIdentifier();
void AdvanceForComment();
- void RaiseError() {
- m_token.reset();
- m_lexer_error = true;
- }
+ void RaiseError() { m_lexer_error = true; }
const wchar_t* m_cursor;
const wchar_t* const m_end;
uint32_t m_current_line;
- std::unique_ptr<CXFA_FMToken> m_token;
bool m_lexer_error;
};