Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(244)

Side by Side Diff: xfa/src/fxfa/src/fm2js/xfa_lexer.h

Issue 1701363003: Fix some issues with CXFA_FMParse/CXFA_FMLexer infinite looping. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: delete more stuff Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #ifndef _XFA_FM_LEXER_H 7 #ifndef _XFA_FM_LEXER_H
8 #define _XFA_FM_LEXER_H 8 #define _XFA_FM_LEXER_H
9
10 #include <memory>
11
9 enum XFA_FM_TOKEN { 12 enum XFA_FM_TOKEN {
10 TOKand, 13 TOKand,
11 TOKlparen, 14 TOKlparen,
12 TOKrparen, 15 TOKrparen,
13 TOKmul, 16 TOKmul,
14 TOKplus, 17 TOKplus,
15 TOKcomma, 18 TOKcomma,
16 TOKminus, 19 TOKminus,
17 TOKdot, 20 TOKdot,
18 TOKdiv, 21 TOKdiv,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 TOKstar, 72 TOKstar,
70 TOKidentifier, 73 TOKidentifier,
71 TOKunderscore, 74 TOKunderscore,
72 TOKdollar, 75 TOKdollar,
73 TOKexclamation, 76 TOKexclamation,
74 TOKcall, 77 TOKcall,
75 TOKstring, 78 TOKstring,
76 TOKnumber, 79 TOKnumber,
77 TOKreserver 80 TOKreserver
78 }; 81 };
82
79 struct XFA_FMKeyword { 83 struct XFA_FMKeyword {
80 XFA_FM_TOKEN m_type; 84 XFA_FM_TOKEN m_type;
81 uint32_t m_uHash; 85 uint32_t m_uHash;
82 const FX_WCHAR* m_keword; 86 const FX_WCHAR* m_keword;
83 }; 87 };
88
84 const FX_WCHAR* XFA_FM_KeywordToString(XFA_FM_TOKEN op); 89 const FX_WCHAR* XFA_FM_KeywordToString(XFA_FM_TOKEN op);
90
85 class CXFA_FMToken { 91 class CXFA_FMToken {
86 public: 92 public:
87 CXFA_FMToken(); 93 CXFA_FMToken();
88 CXFA_FMToken(FX_DWORD uLineNum); 94 CXFA_FMToken(FX_DWORD uLineNum);
Tom Sepez 2016/02/18 00:39:14 nit: explicit
Oliver Chang 2016/02/18 00:49:02 Done.
89 ~CXFA_FMToken();
90 CFX_WideStringC m_wstring; 95 CFX_WideStringC m_wstring;
91 XFA_FM_TOKEN m_type; 96 XFA_FM_TOKEN m_type;
Tom Sepez 2016/02/18 00:39:14 nit: maybe blank line between methods and members,
Oliver Chang 2016/02/18 00:49:02 Done.
92 FX_DWORD m_uLinenum; 97 FX_DWORD m_uLinenum;
93 CXFA_FMToken* m_pNext;
94 }; 98 };
99
95 class CXFA_FMLexer { 100 class CXFA_FMLexer {
96 public: 101 public:
97 CXFA_FMLexer(const CFX_WideStringC& wsFormcalc, CXFA_FMErrorInfo* pErrorInfo); 102 CXFA_FMLexer(const CFX_WideStringC& wsFormcalc, CXFA_FMErrorInfo* pErrorInfo);
98 ~CXFA_FMLexer();
99 CXFA_FMToken* NextToken(); 103 CXFA_FMToken* NextToken();
100 FX_DWORD Number(CXFA_FMToken* t, const FX_WCHAR* p, const FX_WCHAR*& pEnd); 104 FX_DWORD Number(CXFA_FMToken* t, const FX_WCHAR* p, const FX_WCHAR*& pEnd);
101 FX_DWORD String(CXFA_FMToken* t, const FX_WCHAR* p, const FX_WCHAR*& pEnd); 105 FX_DWORD String(CXFA_FMToken* t, const FX_WCHAR* p, const FX_WCHAR*& pEnd);
102 FX_DWORD Identifiers(CXFA_FMToken* t, 106 FX_DWORD Identifiers(CXFA_FMToken* t,
103 const FX_WCHAR* p, 107 const FX_WCHAR* p,
104 const FX_WCHAR*& pEnd); 108 const FX_WCHAR*& pEnd);
105 void Comment(const FX_WCHAR* p, const FX_WCHAR*& pEnd); 109 void Comment(const FX_WCHAR* p, const FX_WCHAR*& pEnd);
106 XFA_FM_TOKEN IsKeyword(const CFX_WideStringC& p); 110 XFA_FM_TOKEN IsKeyword(const CFX_WideStringC& p);
107 void SetCurrentLine(FX_DWORD line) { m_uCurrentLine = line; } 111 void SetCurrentLine(FX_DWORD line) { m_uCurrentLine = line; }
108 void SetToken(CXFA_FMToken* pToken) { 112 void SetToken(CXFA_FMToken* pToken) {
109 if (m_pToken) { 113 if (m_pToken.get() != pToken)
110 delete m_pToken; 114 m_pToken.reset(pToken);
111 }
112 m_pToken = pToken;
113 } 115 }
114 const FX_WCHAR* SavePos() { return m_ptr; } 116 const FX_WCHAR* SavePos() { return m_ptr; }
115 void RestorePos(const FX_WCHAR* pPos) { m_ptr = pPos; } 117 void RestorePos(const FX_WCHAR* pPos) { m_ptr = pPos; }
116 void Error(XFA_FM_ERRMSG msg, ...); 118 void Error(XFA_FM_ERRMSG msg, ...);
117 FX_BOOL HasError() const; 119 FX_BOOL HasError() const;
118 120
119 protected: 121 protected:
120 CXFA_FMToken* Scan(); 122 CXFA_FMToken* Scan();
121 const FX_WCHAR* m_pScript;
122 const FX_WCHAR* m_ptr; 123 const FX_WCHAR* m_ptr;
123 FX_STRSIZE m_uLength;
124 FX_DWORD m_uCurrentLine; 124 FX_DWORD m_uCurrentLine;
125 CXFA_FMToken* m_pToken; 125 std::unique_ptr<CXFA_FMToken> m_pToken;
126 CXFA_FMErrorInfo* m_pErrorInfo; 126 CXFA_FMErrorInfo* m_pErrorInfo;
127 }; 127 };
128
128 #endif 129 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698