88 size_t initLineNumber = 0);
143 m_SavedNestingLevel = m_NestLevel;
149 m_NestLevel = m_SavedNestingLevel;
163 wxString ReadToEOL(
bool stripUnneeded =
true);
168 void ReadParentheses(
wxString& str);
174 bool SkipToInlineCommentEnd();
179 return m_TokenIndex >= m_BufferLen;
185 return m_TokenIndex < m_BufferLen;
224 bool ReplaceBufferText(
const wxString& target,
const Token* macro = 0);
232 bool ReplaceMacroUsage(
const Token* tk);
251 int GetFirstTokenPosition(
const wxChar* buffer,
const size_t bufferLen,
252 const wxChar* key,
const size_t keyLen);
257 int KMP_Find(
const wxChar* text,
const wxChar* pattern,
const int patternLen);
260 void SetLastTokenIdx(
int tokenIdx);
276 bool CheckMacroUsageAndReplace();
289 bool IsEscapedChar();
292 bool SkipToChar(
const wxChar& ch);
298 bool SkipWhiteSpace();
313 bool SkipPreprocessorBranch();
325 bool SkipToStringEnd(
const wxChar& ch);
328 bool MoveToNextChar();
333 if(m_TokenIndex < m_BufferLen)
334 return m_Buffer.GetChar(m_TokenIndex);
349 if ((m_TokenIndex + 1) >= m_BufferLen)
352 return m_Buffer.GetChar(m_TokenIndex + 1);
358 if (m_TokenIndex > 0 && m_BufferLen > 0)
359 return m_Buffer.GetChar(m_TokenIndex - 1);
369 for (
int i = 0; i < len; ++i)
388 wxChar last = PreviousChar();
390 if (last ==
_T(
'\r') && m_TokenIndex >= 2)
391 return m_Buffer.GetChar(m_TokenIndex - 2) ==
_T(
'\\');
392 return last ==
_T(
'\\');
396 bool CalcConditionExpression();
408 bool IsMacroDefined();
411 void HandleDefines();
438 void SkipToNextConditionPreprocessor();
453 void SkipToEndConditionPreprocessor();
486 bool GetMacroExpandedText(
const Token* tk,
wxString& expandedText);
489 void KMP_GetNextVal(
const wxChar* pattern,
int next[]);
657 #endif // TOKENIZER_H std::stack< bool > m_ExpressionResult
preprocessor branch stack, if we meet a #if 1, then the value true will be pushed to to the stack...
bool wantPreprocessor
do we expand the macros in #if like conditional preprocessor directives
PreprocessorType
Enum categorizing C-preprocessor directives.
void SetTokenizerOption(bool wantPreprocessor, bool storeDocumentation)
Handle condition preprocessor and store documentation or not.
wxChar PreviousChar() const
Return (peek) the previous character.
unsigned int m_NestLevel
keep track of block nesting { }
unsigned int m_SavedNestingLevel
void RestoreNestingLevel()
Restore the brace level.
const wxString & GetFilename() const
Return the opened files name.
unsigned int m_BufferLen
Buffer length.
read parentheses as token lists, so it return several tokens like '(' ...
unsigned int m_Begin
the token index we begin to parse after replacement
size_t wxStrlen(const wxCharBuffer &s)
std::list< ExpandedMacro > m_ExpandedMacros
this serves as a macro replacement stack, in the above example, if AAA is replaced by BBBB...
wxChar CurrentChar() const
Return the current character indexed(pointed) by m_TokenIndex in the m_Buffer.
wxString m_Token
These variables define the current token string and its auxiliary information, such as the token name...
TokenizerOptions m_TokenizerOptions
Tokenizer options specify the token reading option.
bool IsBackslashBeforeEOL()
Check the previous char before EOL is a backslash, call this function in the condition that the Curre...
unsigned int GetNestingLevel() const
Return the brace "{}" level.
unsigned int m_LineNumber
line offset in buffer, please note that it is 1 based, not 0 based
unsigned int m_FileIdx
File index, useful when parsing documentation;.
unsigned int m_PeekNestLevel
a container class to hold all the Tokens getting from parsing stage
wxString m_NextTokenDoc
normally, this record the doxygen style comments for the next token definition for example...
int GetFirstTokenPosition(const wxString &buffer, const wxString &target)
Search "target" in the buffer, return first position in buffer.
unsigned int m_End
the end token index, if beyond this index, we need to pop the buffer
unsigned int GetLineNumber() const
Return the line number of the current token string.
unsigned int m_PeekLineNumber
wxString m_Filename
Filename of the buffer.
This is just a simple lexer class.
bool m_IsOK
bool variable specifies whether the buffer is ready for parsing
wxString m_Lex
a lexeme string return by the Lex() function, this is a candidate token string, which may be replaced...
int m_LastTokenIdx
store the recent added token index for example, here is a comment
#include #warning and other #xxx
wxUSE_UNICODE_dependent wxChar
bool m_ReadingMacroDefinition
indicates whether we are reading the macro definition This variable will affect how the doxygen comme...
a symbol found in the parsed files, it can be many kinds, such as a variable, a class and so on...
unsigned int m_UndoNestLevel
void SetState(TokenizerState state)
Set the Tokenizer skipping options.
bool NotEOF() const
return true if it is Not the end of buffer
unsigned int m_TokenIndex
index offset in buffer, when parsing a buffer
replaced buffer information Here is an example of how macro are expanded
TokenTree * m_TokenTree
the Token tree to store the macro definition, the token tree is shared with Parserthread ...
TokenizerState m_State
Tokeniser state specifies the token reading option.
unsigned int m_UndoTokenIndex
Backup the previous Token information.
bool CharInString(const wxChar ch, const wxChar *chars) const
Check if a ch matches any characters in the wxChar array.
const Token * m_Macro
the referenced used macro
TokenizerState
Enum defines the skip state of the Tokenizer.
bool storeDocumentation
do we store the doxygen like document
unsigned int m_SavedLineNumber
LoaderBase * m_Loader
File loader, it load the content to the m_Buffer, either from the harddisk or memory.
unsigned int m_UndoLineNumber
unsigned int m_PeekTokenIndex
bool IsOK() const
If the buffer is correctly loaded, this function return true.
bool m_PeekAvailable
Peek token information.
read parentheses as a single token
wxChar NextChar() const
Return (peek) the next character.
void SaveNestingLevel()
Save the brace "{" level, the parser might need to ignore the nesting level in some cases...
Whether we need to handle C-preprocessor directives.
unsigned int m_SavedTokenIndex
Saved token info (for PeekToken()), m_TokenIndex will be moved forward or backward when either DoGetT...
wxChar CurrentCharMoveNext()
Do the previous two functions sequentially.
wxString m_Buffer
Buffer content, all the lexical analysis is operating on this member variable.
const wxCStrData GetData() const
bool IsEOF() const
Check whether the Tokenizer reaches the end of the buffer (file)
TokenizerState GetState()
Return the token reading options value,.