Code::Blocks  SVN r11506
Public Member Functions | Protected Types | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
ParserThread Class Reference

A parser threaded task, which can be assigned to the thread task pool, and run there. More...

#include <parserthread.h>

Inheritance diagram for ParserThread:
Collaboration diagram for ParserThread:

Public Member Functions

 ParserThread (ParserBase *parent, const wxString &bufferOrFilename, bool isLocal, ParserThreadOptions &parserThreadOptions, TokenTree *tokenTree)
 ParserThread constructor. More...
 
virtual ~ParserThread ()
 ParserThread destructor. More...
 
bool Parse ()
 Do the main job (syntax analysis) here. More...
 
bool ParseBufferForNamespaces (const wxString &buffer, NameSpaceVec &result)
 Get the context "namespace XXX { ... }" directive. More...
 
bool ParseBufferForUsingNamespace (const wxString &buffer, wxArrayString &result)
 Get the context "using namespace XXX" directive. More...
 
wxString GetFilename ()
 
- Public Member Functions inherited from cbThreadedTask
 cbThreadedTask ()
 cbThreadedTask ctor More...
 
virtual ~cbThreadedTask ()=0
 cbThreadedTask dtor More...
 
void Abort ()
 This function is called to tell the task to abort (check cbThreadPool::AbortAllTasks) More...
 

Protected Types

enum  EClassType { ctStructure = 0, ctClass = 1, ctUnion = 3 }
 specify which "class like type" we are handling: struct or class or union More...
 

Protected Member Functions

int Execute ()
 Execute() is a virtual function derived from cbThreadedTask class, we should override it here. More...
 
wxChar SkipToOneOfChars (const wxString &chars, bool supportNesting=false, bool singleCharToken=true)
 Continuously eat the tokens until we meet one of the matching characters. More...
 
void DoParse ()
 actually run the syntax analysis More...
 
void SkipBlock ()
 skip blocks {} More...
 
void SkipAngleBraces ()
 skip the template argument More...
 
void HandleIncludes ()
 handle include <XXXX> or include "XXXX" directive. More...
 
void HandleNamespace ()
 handle the statement: namespace XXX { More...
 
void HandleClass (EClassType ct)
 handle class declaration More...
 
void HandleFunction (wxString &name, bool isOperator=false, bool isPointer=false)
 handle function declaration or definition More...
 
void HandleForLoopArguments ()
 parse for loop arguments: for(int X; ... More...
 
void HandleConditionalArguments ()
 parse arguments like: if(int X = getNumber()) More...
 
void HandleEnum ()
 handle enum declaration More...
 
bool CalcEnumExpression (Token *tokenParent, long &result, wxString &peek)
 calculate the value assigned to enumerator More...
 
void HandleTypedef ()
 handle typedef directive More...
 
bool ReadVarNames ()
 eg: class ClassA{...} varA, varB, varC This function will read the "varA, varB, varC" More...
 
bool ReadClsNames (wxString &ancestor)
 handle class names, e.g., the code below More...
 
wxString ReadAngleBrackets ()
 read <> as a whole token More...
 
TokenDoAddToken (TokenKind kind, const wxString &name, int line, int implLineStart=0, int implLineEnd=0, const wxString &args=wxEmptyString, bool isOperator=false, bool isImpl=false)
 add one token to the token tree More...
 
wxString GetTokenBaseType ()
 return the actual token's base type. More...
 
- Protected Member Functions inherited from cbThreadedTask
bool TestDestroy () const
 Be sure to call this function often. If it returns true, quit your task quickly. More...
 
bool Aborted () const
 Same as TestDestroy() More...
 

Private Member Functions

bool InitTokenizer ()
 initialize the m_Buffer, load from local file or use a buffer in memory More...
 
TokenTokenExists (const wxString &name, const Token *parent=0, short int kindMask=0xFFFF)
 if parent is 0, then global namespace will be used, all tokens under parent scope are searched More...
 
TokenTokenExists (const wxString &name, const wxString &baseArgs, const Token *parent, TokenKind kind)
 Support function overloading. More...
 
TokenFindTokenFromQueue (std::queue< wxString > &q, Token *parent=0, bool createIfNotExist=false, Token *parentIfCreated=0)
 TODO comment here? More...
 
bool GetBaseArgs (const wxString &args, wxString &baseArgs)
 Converts a full argument list (including variable names) to argument types only and strips spaces. More...
 
void GetTemplateArgs ()
 Read the <xxxx=yyy, zzz> , and store the value in m_TemplateArgs. More...
 
void ResolveTemplateArgs (Token *newToken)
 this function just associate the formal template argument to actual argument For example, we have such code: More...
 
wxArrayString GetTemplateArgArray (const wxString &templateArgs, bool remove_gt_lt, bool add_last)
 normally the template argument is all in a wxString, this function just split them to a wxArrayString, each element is an actual argument. More...
 
void SplitTemplateFormalParameters (const wxString &templateArgs, wxArrayString &formals)
 Split formal template argument list. More...
 
void SplitTemplateActualParameters (const wxString &templateArgs, wxArrayString &actuals)
 Split actual template argument list. More...
 
bool ResolveTemplateMap (const wxString &typeStr, const wxArrayString &actuals, std::map< wxString, wxString > &results)
 associate formal argument with actual template argument More...
 
void RemoveTemplateArgs (const wxString &expr, wxString &expNoArgs, wxString &templateArgs)
 remove template arguments from an expression example: 'std::list<string>' will be separated into 'std::list' and '<string>' More...
 
bool IsStillAlive (const wxString &funcInfo)
 Only for debug. More...
 
void RefineAnonymousTypeToken (short int typeMask, wxString alise)
 change an anonymous(unnamed) token's name to a human readable name, the m_Str is expect to store the unnamed token name, for example, for parsing the code More...
 

Private Attributes

Tokenizer m_Tokenizer
 if we regard the parserThread class as a syntax analyzer, then the Tokenizer class is regard as the lexer, which always feeds a wxString by calling m_Tokenizer.GetToken() More...
 
ParserBasem_Parent
 a pointer to its parent Parser object, the Parserthread class has two place to communicate with Parser class. More...
 
TokenTreem_TokenTree
 a pointer to the token tree, all the tokens will be added to that tree structure More...
 
Tokenm_LastParent
 parent Token, for example, when you are parsing in the class member variables, m_LastParent holds a pointer to the current context, which is a token holding class name More...
 
TokenScope m_LastScope
 this member define the scope type of member variables, which is: public, private protected or undefined More...
 
wxString m_Filename
 the file name of the parsing source More...
 
unsigned int m_FileSize
 file size, actually the length of the wxString More...
 
unsigned int m_FileIdx
 source file index on the "file map tree" More...
 
bool m_IsLocal
 if true, means we are parsing a file which belongs to a C::B project, otherwise, we are parsing a file not belong to a C::B project(such as a system header file) More...
 
wxString m_Str
 This is a very important member variables! It serves as a type stack, eg: parsing the statement: "unsigned int const varA;" we determine 'varA' is a token variable, until we searching to the last semicolon. More...
 
wxString m_LastToken
 hold the previous token string More...
 
ParserThreadOptions m_Options
 parser options, see the ParserThreadOptions structure More...
 
std::queue< wxStringm_EncounteredNamespaces
 for member funcs implementation or a function declaration below eg: int ClassA::FunctionB(); EncounteredNamespaces is 'ClassA' More...
 
std::queue< wxStringm_EncounteredTypeNamespaces
 namespaces in function return types for a function declaration below: e.g. More...
 
TokenIdxSet m_UsedNamespacesIds
 globally included namespaces by "using namespace" statement More...
 
wxString m_LastUnnamedTokenName
 TODO: describe me here. More...
 
bool m_ParsingTypedef
 this makes a difference in unnamed class/struct/enum handling More...
 
wxString m_Buffer
 a wxString holding the parsing buffer, if it is a file in the hard disk, then this stands for the file name. More...
 
wxString m_PointerOrRef
 a pointer indicator or a references More...
 
wxString m_TemplateArgument
 holds current template argument(s) when a template occurs More...
 
size_t m_StructUnionUnnamedCount
 
size_t m_EnumUnnamedCount
 

Detailed Description

A parser threaded task, which can be assigned to the thread task pool, and run there.

This class represents a worker threaded task for the Code Completion plug-in, the main task is doing the syntax analysis and add every token to the token tree. The Token tree (sometimes, we call it TokenTree ) is a Patricia tree structure, more details can be seen in token.h and token.cpp. The buffer can either be loaded from a local file or directly used of a wxString.

Definition at line 138 of file parserthread.h.

Member Enumeration Documentation

◆ EClassType

enum ParserThread::EClassType
protected

specify which "class like type" we are handling: struct or class or union

Enumerator
ctStructure 
ctClass 
ctUnion 

Definition at line 181 of file parserthread.h.

Constructor & Destructor Documentation

◆ ParserThread()

ParserThread::ParserThread ( ParserBase parent,
const wxString bufferOrFilename,
bool  isLocal,
ParserThreadOptions parserThreadOptions,
TokenTree tokenTree 
)

ParserThread constructor.

Parameters
parentthe parent Parser object which contain the token tree.
bufferOrFilenameit's either the filename to open or a wxString buffer already in memory.
isLocaldetermine whether this is a file locally belong to a cbp or in other global paths.
parserThreadOptionsparser thread options, see ParserThreadOptions Class for details.
tokenTreeit is the tree structure holding all the tokens, ParserThread will add every token when it parsed.

Definition at line 197 of file parserthread.cpp.

References _T, cbThrow, m_Tokenizer, m_TokenTree, Tokenizer::SetTokenizerOption(), ParserThreadOptions::storeDocumentation, and ParserThreadOptions::wantPreprocessor.

◆ ~ParserThread()

ParserThread::~ParserThread ( )
virtual

ParserThread destructor.

Definition at line 222 of file parserthread.cpp.

References ParserThreadOptions::loader, m_Options, and LoaderBase::Sync().

Member Function Documentation

◆ CalcEnumExpression()

bool ParserThread::CalcEnumExpression ( Token tokenParent,
long &  result,
wxString peek 
)
protected

◆ DoAddToken()

Token * ParserThread::DoAddToken ( TokenKind  kind,
const wxString name,
int  line,
int  implLineStart = 0,
int  implLineEnd = 0,
const wxString args = wxEmptyString,
bool  isOperator = false,
bool  isImpl = false 
)
protected

add one token to the token tree

Parameters
kindToken type, see Emun for more details
nameToken name, this is the key string to be searched in the token tree
lineline number of the source file where the current Token locates
implLineStartif this is a function implementation, it is the start of function body
implLineEndlike the one above, it is the end line of the function implementation body
argsif the token type is a function, this is the function arguments
isOperatorbool variable to determine an operator override function or not
isTmplbool variable to determine it is a function declaration or implementation

Definition at line 1475 of file parserthread.cpp.

References _T, Token::AddChild(), ADDTOKEN, TokenTree::at(), wxString::Clear(), ParserConsts::dcolon, wxString::Find(), FindTokenFromQueue(), GetBaseArgs(), GetTokenBaseType(), Token::GetTokenKindString(), TokenTree::insert(), TokenTree::InsertTokenBelongToFile(), wxString::IsEmpty(), ParserThreadOptions::isTemp, Token::m_Args, Token::m_BaseArgs, Token::m_BaseType, m_EncounteredNamespaces, m_EncounteredTypeNamespaces, Token::m_FileIdx, m_FileIdx, Token::m_FullType, Token::m_ImplFileIdx, Token::m_ImplLine, Token::m_ImplLineEnd, Token::m_ImplLineStart, Token::m_Index, Token::m_IsLocal, m_IsLocal, Token::m_IsOperator, Token::m_IsTemp, m_LastParent, m_LastScope, Token::m_Line, Token::m_Name, m_Options, Token::m_ParentIndex, m_PointerOrRef, Token::m_Scope, m_Str, Token::m_TemplateArgument, m_TemplateArgument, m_Tokenizer, Token::m_TokenKind, TokenTree::m_TokenTicketCount, m_TokenTree, ParserThreadOptions::parentIdxOfBuffer, wxString::Prepend(), Tokenizer::SetLastTokenIdx(), ParserConsts::space_chr(), ParserConsts::tilde, tkAnyContainer, tkAnyFunction, tkClass, tkConstructor, tkDestructor, tkVariable, TokenExists(), TRACE, wxString::Trim(), wxString::wx_str(), wxEmptyString, and wxNOT_FOUND.

Referenced by DoParse(), HandleClass(), HandleConditionalArguments(), HandleEnum(), HandleForLoopArguments(), HandleFunction(), HandleNamespace(), HandleTypedef(), ReadClsNames(), and ReadVarNames().

◆ DoParse()

void ParserThread::DoParse ( )
protected

actually run the syntax analysis

Definition at line 545 of file parserthread.cpp.

References _T, ParserThreadOptions::bufferSkipBlocks, ParserConsts::clarray, ParserConsts::clbrace_chr(), wxString::Clear(), wxString::clear(), ParserConsts::colon, ParserConsts::colon_chr(), ParserConsts::comma, ParserConsts::comma_chr(), ParserConsts::commasemicolonopbrace, ctClass, ctStructure, ctUnion, ParserConsts::dash, ParserConsts::dash_chr(), ParserConsts::dcolon, DoAddToken(), ParserConsts::dot_chr(), ParserConsts::equals, ParserConsts::equals_chr(), wxString::find(), FindTokenFromQueue(), wxString::GetChar(), Tokenizer::GetLineNumber(), wxStringTokenizer::GetNextToken(), Tokenizer::GetState(), GetTemplateArgs(), Tokenizer::GetToken(), ParserConsts::gt_chr(), HandleClass(), ParserThreadOptions::handleClasses, HandleConditionalArguments(), HandleEnum(), ParserThreadOptions::handleEnums, HandleForLoopArguments(), HandleFunction(), ParserThreadOptions::handleFunctions, HandleIncludes(), HandleNamespace(), HandleTypedef(), ParserThreadOptions::handleTypedefs, ParserThreadOptions::handleVars, ParserConsts::hash_chr(), wxStringTokenizer::HasMoreTokens(), IS_ALIVE, wxString::IsEmpty(), wxString::IsSameAs(), Token::IsValidAncestor(), ParserConsts::kw___asm, ParserConsts::kw___at, ParserConsts::kw__C_, ParserConsts::kw__CPP_, ParserConsts::kw_attribute, ParserConsts::kw_case, ParserConsts::kw_catch, ParserConsts::kw_class, ParserConsts::kw_const, ParserConsts::kw_declspec, ParserConsts::kw_delete, ParserConsts::kw_do, ParserConsts::kw_else, ParserConsts::kw_enum, ParserConsts::kw_extern, ParserConsts::kw_for, ParserConsts::kw_friend, ParserConsts::kw_if, ParserConsts::kw_include, ParserConsts::kw_inline, ParserConsts::kw_namespace, ParserConsts::kw_noexcept, ParserConsts::kw_operator, ParserConsts::kw_private, ParserConsts::kw_protected, ParserConsts::kw_public, ParserConsts::kw_return, ParserConsts::kw_static, ParserConsts::kw_struct, ParserConsts::kw_switch, ParserConsts::kw_template, ParserConsts::kw_typedef, ParserConsts::kw_union, ParserConsts::kw_using, ParserConsts::kw_virtual, ParserConsts::kw_volatile, ParserConsts::kw_while, wxString::Length(), ParserConsts::lt, Token::m_AncestorsString, Token::m_BaseType, m_EncounteredNamespaces, m_EncounteredTypeNamespaces, Token::m_FullType, Token::m_Index, m_LastParent, m_LastScope, m_LastToken, m_LastUnnamedTokenName, Token::m_Name, m_Options, m_PointerOrRef, m_Str, m_TemplateArgument, m_Tokenizer, Token::m_TokenKind, m_UsedNamespacesIds, Tokenizer::NotEOF(), ParserConsts::oparray_chr(), ParserConsts::opbrace, ParserConsts::opbrace_chr(), ParserConsts::opbracket_chr(), Tokenizer::PeekToken(), ParserConsts::plus_chr(), ParserConsts::ptr, ParserConsts::ptr_chr(), ParserConsts::question_chr(), ReadAngleBrackets(), ParserConsts::ref_chr(), ResolveTemplateArgs(), ParserConsts::semicolon, ParserConsts::semicolon_chr(), ParserConsts::semicolonclbrace, ParserConsts::semicolonopbrace, Tokenizer::SetState(), SkipAngleBraces(), SkipBlock(), Tokenizer::SkipToEOL(), SkipToOneOfChars(), ParserConsts::space_chr(), wxString::StartsWith(), tkNamespace, tkTypedef, tkVariable, TRACE, wxString::Trim(), tsNormal, tsPrivate, tsProtected, tsPublic, tsUndefined, ParserConsts::underscore_chr(), Tokenizer::UngetToken(), ParserThreadOptions::useBuffer, wxString::wx_str(), wxIsalpha(), and wxNOT_FOUND.

Referenced by HandleClass(), HandleNamespace(), and Parse().

◆ Execute()

int ParserThread::Execute ( )
inlineprotectedvirtual

Execute() is a virtual function derived from cbThreadedTask class, we should override it here.

In the batch parsing mode, a lot of parser threads were generated and executed concurrently, this often happens when user open a project. Every parserthread task will firstly be added to the thread pool, later called automatically from the thread pool.

Implements cbThreadedTask.

Definition at line 188 of file parserthread.h.

References CC_LOCKER_TRACK_TT_MTX_LOCK, CC_LOCKER_TRACK_TT_MTX_UNLOCK, s_TokenTreeMutex, and wxEmptyString.

◆ FindTokenFromQueue()

Token * ParserThread::FindTokenFromQueue ( std::queue< wxString > &  q,
Token parent = 0,
bool  createIfNotExist = false,
Token parentIfCreated = 0 
)
private

◆ GetBaseArgs()

bool ParserThread::GetBaseArgs ( const wxString args,
wxString baseArgs 
)
private

Converts a full argument list (including variable names) to argument types only and strips spaces.

eg: if the argument list is like "(const TheClass* the_class = 0x1234, int my_int = 567)" then, the returned argument list is "(const TheClass*,int)"

Parameters
argsFull argument list
baseArgsargument types only
Returns
if failed, will return false, so, it must be a variable

Definition at line 3231 of file parserthread.cpp.

References _T, wxString::Alloc(), ParserConsts::clarray_chr(), ParserConsts::clbracket_chr(), ParserConsts::colon_chr(), ParserConsts::comma_chr(), ParserConsts::eol_chr(), wxString::Find(), ParserConsts::gt_chr(), ParserConsts::kw_attribute, ParserConsts::kw_const, ParserConsts::kw_enum, ParserConsts::kw_volatile, wxString::Len(), ParserConsts::lt_chr(), wxString::Mid(), ParserConsts::null(), ParserConsts::oparray_chr(), ParserConsts::opbracket_chr(), ParserConsts::ptr, ParserConsts::ptr_chr(), ParserConsts::ref_chr(), ParserConsts::space_chr(), TRACE, ParserConsts::underscore_chr(), wxString::wx_str(), wxIsalnum(), and wxNOT_FOUND.

Referenced by DoAddToken().

◆ GetFilename()

wxString ParserThread::GetFilename ( )
inline

Definition at line 177 of file parserthread.h.

◆ GetTemplateArgArray()

wxArrayString ParserThread::GetTemplateArgArray ( const wxString templateArgs,
bool  remove_gt_lt,
bool  add_last 
)
private

◆ GetTemplateArgs()

void ParserThread::GetTemplateArgs ( )
private

◆ GetTokenBaseType()

wxString ParserThread::GetTokenBaseType ( )
protected

return the actual token's base type.

e.g.: if the token type string is: "const wxString &" then, the actual token base type is : "wxString"

Definition at line 1351 of file parserthread.cpp.

References _T, ParserConsts::colon_chr(), wxString::GetChar(), wxString::IsSameAs(), ParserConsts::kw_const, wxString::Length(), m_Str, wxString::Mid(), ParserConsts::ptr_chr(), ParserConsts::ref_chr(), wxString::Remove(), TRACE, ParserConsts::underscore_chr(), wxString::wx_str(), wxIsalnum(), and wxIsspace().

Referenced by DoAddToken().

◆ HandleClass()

void ParserThread::HandleClass ( EClassType  ct)
protected

handle class declaration

Parameters
ctspecify class like type : struct or enum or class

Definition at line 1882 of file parserthread.cpp.

References _T, wxString::Clear(), ParserConsts::colon, ParserConsts::comma, ParserConsts::comma_chr(), ctClass, ctUnion, ParserConsts::dcolon, DoAddToken(), DoParse(), ParserConsts::equals, wxString::GetChar(), wxArrayString::GetCount(), Tokenizer::GetLineNumber(), wxStringTokenizer::GetNextToken(), Tokenizer::GetState(), GetStringFromArray(), GetTemplateArgs(), Tokenizer::GetToken(), ParserConsts::gt, HandleFunction(), ParserThreadOptions::handleVars, wxStringTokenizer::HasMoreTokens(), IS_ALIVE, wxString::IsEmpty(), wxArrayString::IsEmpty(), ParserConsts::kw_attribute, ParserConsts::kw_declspec, ParserConsts::kw_private, ParserConsts::kw_protected, ParserConsts::kw_public, ParserConsts::lt, Token::m_AncestorsString, m_FileIdx, Token::m_ImplLine, Token::m_ImplLineEnd, Token::m_ImplLineStart, Token::m_IsAnonymous, m_LastParent, m_LastScope, m_LastUnnamedTokenName, Token::m_Name, m_Options, m_ParsingTypedef, m_PointerOrRef, m_Str, m_StructUnionUnnamedCount, Token::m_TemplateArgument, m_TemplateArgument, Token::m_TemplateType, m_Tokenizer, Token::m_TokenKind, ParserConsts::opbrace, ParserConsts::opbracket_chr(), Tokenizer::PeekToken(), wxString::Prepend(), wxString::Printf(), ParserConsts::ptr_chr(), ReadClsNames(), ReadVarNames(), ParserConsts::ref_chr(), ParserConsts::semicolon, Tokenizer::SetState(), SkipAngleBraces(), SkipToOneOfChars(), ParserConsts::space, ParserConsts::space_chr(), SplitTemplateFormalParameters(), tkClass, tkVariable, TokenExists(), TRACE, tsNormal, tsPrivate, tsPublic, Tokenizer::UngetToken(), and wxString::wx_str().

Referenced by DoParse(), and HandleTypedef().

◆ HandleConditionalArguments()

void ParserThread::HandleConditionalArguments ( )
protected

◆ HandleEnum()

void ParserThread::HandleEnum ( )
protected

◆ HandleForLoopArguments()

void ParserThread::HandleForLoopArguments ( )
protected

◆ HandleFunction()

void ParserThread::HandleFunction ( wxString name,
bool  isOperator = false,
bool  isPointer = false 
)
protected

◆ HandleIncludes()

void ParserThread::HandleIncludes ( )
protected

◆ HandleNamespace()

void ParserThread::HandleNamespace ( )
protected

◆ HandleTypedef()

void ParserThread::HandleTypedef ( )
protected

◆ InitTokenizer()

bool ParserThread::InitTokenizer ( )
private

◆ IsStillAlive()

bool ParserThread::IsStillAlive ( const wxString funcInfo)
private

Only for debug.

Definition at line 3740 of file parserthread.cpp.

References _T, cbThreadedTask::TestDestroy(), and TRACE.

◆ Parse()

bool ParserThread::Parse ( )

◆ ParseBufferForNamespaces()

bool ParserThread::ParseBufferForNamespaces ( const wxString buffer,
NameSpaceVec result 
)

◆ ParseBufferForUsingNamespace()

bool ParserThread::ParseBufferForUsingNamespace ( const wxString buffer,
wxArrayString result 
)

◆ ReadAngleBrackets()

wxString ParserThread::ReadAngleBrackets ( )
protected

read <> as a whole token

Definition at line 3770 of file parserthread.cpp.

References _T, Tokenizer::GetToken(), wxString::Last(), m_Tokenizer, Tokenizer::NotEOF(), wxEmptyString, and wxT.

Referenced by DoParse().

◆ ReadClsNames()

bool ParserThread::ReadClsNames ( wxString ancestor)
protected

handle class names, e.g., the code below

typedef class AAA{
int m_a;
int m_b;
} BBB,CCC;
Parameters
ancestorclass name = "AAA" this function reads the following "BBB" and "CCC", and regard them as derived classes of "AAA"
Returns
True, if token was handled, false, if an unexpected token was read.

Definition at line 3166 of file parserthread.cpp.

References _T, wxString::clear(), wxString::Clear(), ParserConsts::comma, CCLogger::DebugLog(), DoAddToken(), F(), CCLogger::Get(), Tokenizer::GetFilename(), Tokenizer::GetLineNumber(), Tokenizer::GetToken(), IS_ALIVE, wxString::IsEmpty(), Token::m_AncestorsString, m_LastParent, Token::m_Name, m_PointerOrRef, m_Str, m_Tokenizer, ParserConsts::ptr, RefineAnonymousTypeToken(), ParserConsts::semicolon, wxString::StartsWith(), tkClass, tkTypedef, TRACE, ParserConsts::underscore_chr(), Tokenizer::UngetToken(), wxString::wx_str(), and wxIsalpha().

Referenced by HandleClass(), and HandleTypedef().

◆ ReadVarNames()

bool ParserThread::ReadVarNames ( )
protected

◆ RefineAnonymousTypeToken()

void ParserThread::RefineAnonymousTypeToken ( short int  typeMask,
wxString  alise 
)
private

change an anonymous(unnamed) token's name to a human readable name, the m_Str is expect to store the unnamed token name, for example, for parsing the code

struct
{
int x;
float y;
} abc;

when we first find an anonymous token, which is named _UnnamedStruct1_2, after this function call, the anonymous token name will becomes struct1_abc, and m_Str will changed from _UnnamedStruct1_2 to struct1_abc.

Definition at line 3751 of file parserthread.cpp.

References _T, wxString::Contains(), m_FileIdx, Token::m_IsAnonymous, m_LastParent, m_Str, m_TokenTree, TokenTree::RenameToken(), and TokenExists().

Referenced by ReadClsNames(), and ReadVarNames().

◆ RemoveTemplateArgs()

void ParserThread::RemoveTemplateArgs ( const wxString expr,
wxString expNoArgs,
wxString templateArgs 
)
private

remove template arguments from an expression example: 'std::list<string>' will be separated into 'std::list' and '<string>'

Parameters
exprComplete expression with template arguments
expNoArgsReturned expression without template arguments
templateArgsThe removed template arguments

Definition at line 3688 of file parserthread.cpp.

References wxString::clear(), ParserConsts::gt, ParserConsts::gt_chr(), wxString::length(), ParserConsts::lt, ParserConsts::lt_chr(), and ParserConsts::space.

Referenced by HandleConditionalArguments(), and HandleForLoopArguments().

◆ ResolveTemplateArgs()

void ParserThread::ResolveTemplateArgs ( Token newToken)
private

this function just associate the formal template argument to actual argument For example, we have such code:

template <typename T> class AAA { T m_aaa;};
AAA<int> bbb;

When handling the "bbb", we need to construct a TemplateMap, we store the map in the "bbb"'s member variable, which is "T"->"int".

Definition at line 3517 of file parserthread.cpp.

References _T, wxArrayString::GetCount(), Token::m_FullType, Token::m_TemplateArgument, m_TemplateArgument, Token::m_TemplateMap, Token::m_TemplateType, ResolveTemplateMap(), SplitTemplateActualParameters(), TRACE, and wxString::wx_str().

Referenced by DoParse(), HandleConditionalArguments(), HandleForLoopArguments(), HandleFunction(), and HandleTypedef().

◆ ResolveTemplateMap()

bool ParserThread::ResolveTemplateMap ( const wxString typeStr,
const wxArrayString actuals,
std::map< wxString, wxString > &  results 
)
private

◆ SkipAngleBraces()

void ParserThread::SkipAngleBraces ( )
protected

◆ SkipBlock()

void ParserThread::SkipBlock ( )
protected

◆ SkipToOneOfChars()

wxChar ParserThread::SkipToOneOfChars ( const wxString chars,
bool  supportNesting = false,
bool  singleCharToken = true 
)
protected

Continuously eat the tokens until we meet one of the matching characters.

Parameters
charswxString includes all the matching characters
supportNestingif true, we need to consider the "{" and "}" nesting levels when skipping,
singleCharTokenif true, only single char tokens (like semicolon, brace etc.) are considered (speeds up parsing for queries like this) in this case, the function returned on a match by nesting/brace level preserved.

Definition at line 232 of file parserthread.cpp.

References wxString::Find(), wxString::GetChar(), Tokenizer::GetNestingLevel(), Tokenizer::GetToken(), IS_ALIVE, wxString::IsEmpty(), wxString::length(), m_Tokenizer, ParserConsts::null(), and wxNOT_FOUND.

Referenced by CalcEnumExpression(), DoParse(), HandleClass(), HandleEnum(), HandleFunction(), HandleNamespace(), ParseBufferForNamespaces(), ParseBufferForUsingNamespace(), and ReadVarNames().

◆ SplitTemplateActualParameters()

void ParserThread::SplitTemplateActualParameters ( const wxString templateArgs,
wxArrayString actuals 
)
private

Split actual template argument list.

Definition at line 3592 of file parserthread.cpp.

References _T, wxArrayString::Add(), ParserConsts::comma, wxArrayString::GetCount(), GetTemplateArgArray(), ParserConsts::gt, ParserConsts::lt, and TRACE.

Referenced by ResolveTemplateArgs().

◆ SplitTemplateFormalParameters()

void ParserThread::SplitTemplateFormalParameters ( const wxString templateArgs,
wxArrayString formals 
)
private

Split formal template argument list.

Definition at line 3573 of file parserthread.cpp.

References wxArrayString::Add(), wxArrayString::GetCount(), GetTemplateArgArray(), ParserConsts::kw_class, and ParserConsts::kw_typename.

Referenced by HandleClass().

◆ TokenExists() [1/2]

Token * ParserThread::TokenExists ( const wxString name,
const Token parent = 0,
short int  kindMask = 0xFFFF 
)
private

if parent is 0, then global namespace will be used, all tokens under parent scope are searched

Parameters
namethe search key string
parentparent token pointer, we only search under the parent token scope
kindMaskfilter for the result token, only the specified type of tokens were matched

Definition at line 1321 of file parserthread.cpp.

References TokenTree::at(), Token::m_Index, m_TokenTree, m_UsedNamespacesIds, TokenTree::TokenExists(), and wxNOT_FOUND.

Referenced by DoAddToken(), FindTokenFromQueue(), HandleClass(), HandleEnum(), HandleNamespace(), and RefineAnonymousTypeToken().

◆ TokenExists() [2/2]

Token * ParserThread::TokenExists ( const wxString name,
const wxString baseArgs,
const Token parent,
TokenKind  kind 
)
private

Support function overloading.

Definition at line 1336 of file parserthread.cpp.

References TokenTree::at(), Token::m_Index, m_TokenTree, m_UsedNamespacesIds, TokenTree::TokenExists(), and wxNOT_FOUND.

Member Data Documentation

◆ m_Buffer

wxString ParserThread::m_Buffer
private

a wxString holding the parsing buffer, if it is a file in the hard disk, then this stands for the file name.

Otherwise, this is the in memory buffer content.

Definition at line 467 of file parserthread.h.

Referenced by InitTokenizer().

◆ m_EncounteredNamespaces

std::queue<wxString> ParserThread::m_EncounteredNamespaces
private

for member funcs implementation or a function declaration below eg: int ClassA::FunctionB(); EncounteredNamespaces is 'ClassA'

Definition at line 444 of file parserthread.h.

Referenced by DoAddToken(), DoParse(), HandleFunction(), and ParseBufferForUsingNamespace().

◆ m_EncounteredTypeNamespaces

std::queue<wxString> ParserThread::m_EncounteredTypeNamespaces
private

namespaces in function return types for a function declaration below: e.g.

: ClassC::returnValue ClassA::FunctionB(); m_EncounteredTypeNamespaces is 'ClassC'

Definition at line 451 of file parserthread.h.

Referenced by DoAddToken(), DoParse(), HandleFunction(), and ParseBufferForUsingNamespace().

◆ m_EnumUnnamedCount

size_t ParserThread::m_EnumUnnamedCount
private

Definition at line 477 of file parserthread.h.

Referenced by HandleEnum().

◆ m_FileIdx

unsigned int ParserThread::m_FileIdx
private

source file index on the "file map tree"

Definition at line 419 of file parserthread.h.

Referenced by DoAddToken(), FindTokenFromQueue(), HandleClass(), HandleEnum(), HandleNamespace(), InitTokenizer(), Parse(), and RefineAnonymousTypeToken().

◆ m_Filename

wxString ParserThread::m_Filename
private

the file name of the parsing source

Definition at line 413 of file parserthread.h.

Referenced by HandleFunction(), HandleIncludes(), InitTokenizer(), and Parse().

◆ m_FileSize

unsigned int ParserThread::m_FileSize
private

file size, actually the length of the wxString

Definition at line 416 of file parserthread.h.

Referenced by InitTokenizer().

◆ m_IsLocal

bool ParserThread::m_IsLocal
private

if true, means we are parsing a file which belongs to a C::B project, otherwise, we are parsing a file not belong to a C::B project(such as a system header file)

Definition at line 424 of file parserthread.h.

Referenced by DoAddToken(), FindTokenFromQueue(), and HandleIncludes().

◆ m_LastParent

Token* ParserThread::m_LastParent
private

parent Token, for example, when you are parsing in the class member variables, m_LastParent holds a pointer to the current context, which is a token holding class name

Definition at line 405 of file parserthread.h.

Referenced by DoAddToken(), DoParse(), HandleClass(), HandleEnum(), HandleFunction(), HandleNamespace(), HandleTypedef(), ReadClsNames(), ReadVarNames(), and RefineAnonymousTypeToken().

◆ m_LastScope

TokenScope ParserThread::m_LastScope
private

this member define the scope type of member variables, which is: public, private protected or undefined

Definition at line 410 of file parserthread.h.

Referenced by DoAddToken(), DoParse(), HandleClass(), and HandleNamespace().

◆ m_LastToken

wxString ParserThread::m_LastToken
private

hold the previous token string

Definition at line 435 of file parserthread.h.

Referenced by DoParse().

◆ m_LastUnnamedTokenName

wxString ParserThread::m_LastUnnamedTokenName
private

TODO: describe me here.

Definition at line 459 of file parserthread.h.

Referenced by DoParse(), HandleClass(), HandleEnum(), HandleTypedef(), and ParseBufferForUsingNamespace().

◆ m_Options

ParserThreadOptions ParserThread::m_Options
private

◆ m_Parent

ParserBase* ParserThread::m_Parent
private

a pointer to its parent Parser object, the Parserthread class has two place to communicate with Parser class.

m_Parent->ParseFile() when it see an include directive.

Definition at line 397 of file parserthread.h.

Referenced by HandleIncludes().

◆ m_ParsingTypedef

bool ParserThread::m_ParsingTypedef
private

this makes a difference in unnamed class/struct/enum handling

Definition at line 462 of file parserthread.h.

Referenced by HandleClass(), HandleEnum(), HandleTypedef(), Parse(), ParseBufferForNamespaces(), and ParseBufferForUsingNamespace().

◆ m_PointerOrRef

wxString ParserThread::m_PointerOrRef
private

a pointer indicator or a references

Definition at line 470 of file parserthread.h.

Referenced by DoAddToken(), DoParse(), HandleClass(), HandleConditionalArguments(), HandleForLoopArguments(), HandleTypedef(), ReadClsNames(), and ReadVarNames().

◆ m_Str

wxString ParserThread::m_Str
private

This is a very important member variables! It serves as a type stack, eg: parsing the statement: "unsigned int const varA;" we determine 'varA' is a token variable, until we searching to the last semicolon.

every token before 'varA' will be pushed to m_Str, at this time m_Str = "unsigned int const"

Definition at line 432 of file parserthread.h.

Referenced by DoAddToken(), DoParse(), GetTokenBaseType(), HandleClass(), HandleConditionalArguments(), HandleEnum(), HandleForLoopArguments(), HandleFunction(), HandleTypedef(), ParseBufferForUsingNamespace(), ReadClsNames(), ReadVarNames(), and RefineAnonymousTypeToken().

◆ m_StructUnionUnnamedCount

size_t ParserThread::m_StructUnionUnnamedCount
private

Definition at line 475 of file parserthread.h.

Referenced by HandleClass().

◆ m_TemplateArgument

wxString ParserThread::m_TemplateArgument
private

holds current template argument(s) when a template occurs

Definition at line 473 of file parserthread.h.

Referenced by DoAddToken(), DoParse(), GetTemplateArgs(), HandleClass(), HandleConditionalArguments(), HandleForLoopArguments(), HandleFunction(), HandleTypedef(), and ResolveTemplateArgs().

◆ m_Tokenizer

Tokenizer ParserThread::m_Tokenizer
private

◆ m_TokenTree

TokenTree* ParserThread::m_TokenTree
private

a pointer to the token tree, all the tokens will be added to that tree structure

Definition at line 400 of file parserthread.h.

Referenced by CalcEnumExpression(), DoAddToken(), FindTokenFromQueue(), HandleIncludes(), InitTokenizer(), Parse(), ParserThread(), RefineAnonymousTypeToken(), ResolveTemplateMap(), and TokenExists().

◆ m_UsedNamespacesIds

TokenIdxSet ParserThread::m_UsedNamespacesIds
private

globally included namespaces by "using namespace" statement

Definition at line 456 of file parserthread.h.

Referenced by DoParse(), and TokenExists().


The documentation for this class was generated from the following files: