14 #define CC_PARSER_BASE_DEBUG_OUTPUT 0 16 #if defined(CC_GLOBAL_DEBUG_OUTPUT) 17 #if CC_GLOBAL_DEBUG_OUTPUT == 1 18 #undef CC_PARSER_BASE_DEBUG_OUTPUT 19 #define CC_PARSER_BASE_DEBUG_OUTPUT 1 20 #elif CC_PARSER_BASE_DEBUG_OUTPUT == 2 21 #undef CC_PARSER_BASE_DEBUG_OUTPUT 22 #define CC_PARSER_BASE_DEBUG_OUTPUT 2 27 #define TRACE(format, args...) \ 28 CCLogger::Get()->DebugLog(F(format, ##args)) 29 #define TRACE2(format, args...) \ 30 CCLogger::Get()->DebugLog(F(format, ##args)) 31 #define TRACE2_SET_FLAG(traceFile) 34 #undef CC_LOCKER_TRACK_TT_MTX_LOCK 35 #define CC_LOCKER_TRACK_TT_MTX_LOCK(a) 36 #undef CC_LOCKER_TRACK_TT_MTX_UNLOCK 37 #define CC_LOCKER_TRACK_TT_MTX_UNLOCK(a) 39 #if CC_PARSER_BASE_DEBUG_OUTPUT == 1 40 #define TRACE(format, args...) \ 41 CCLogger::Get()->DebugLog(F(format, ##args)) 42 #define TRACE2(format, args...) 43 #define TRACE2_SET_FLAG(traceFile) 44 #elif CC_PARSER_BASE_DEBUG_OUTPUT == 2 45 #define TRACE(format, args...) \ 48 if (g_EnableDebugTrace) \ 49 CCLogger::Get()->DebugLog(F(format, ##args)); \ 52 #define TRACE2(format, args...) \ 53 CCLogger::Get()->DebugLog(F(format, ##args)) 54 #define TRACE2_SET_FLAG(traceFile) \ 55 g_EnableDebugTrace = !g_DebugTraceFile.IsEmpty() && traceFile.EndsWith(g_DebugTraceFile) 57 #define TRACE(format, args...) 58 #define TRACE2(format, args...) 59 #define TRACE2_SET_FLAG(traceFile) 61 #endif // CC_PARSER_TEST 68 static bool empty_ext =
true;
70 header_ext.
Add(
_T(
"h")); header_ext.
Add(
_T(
"hpp")); header_ext.
Add(
_T(
"tcc")); header_ext.
Add(
_T(
"xpm"));
72 source_ext.
Add(
_T(
"c")); source_ext.
Add(
_T(
"cpp")); source_ext.
Add(
_T(
"cxx")); source_ext.
Add(
_T(
"cc")); source_ext.
Add(
_T(
"c++"));
77 log.
Printf(
wxT(
"ParserDummy::ParserCommon::FileType() : File '%s' is of type 'ftOther' (empty)."), filename.
wx_str());
83 const int pos = file.
Find(
_T(
'.'),
true);
91 log.
Printf(
wxT(
"ParserDummy::ParserCommon::FileType() : File '%s' is of type 'ftHeader' (w/o ext.)."), filename.
wx_str());
96 for (
size_t i=0; i<header_ext.
GetCount(); ++i)
98 if (ext==header_ext[i])
101 log.
Printf(
wxT(
"ParserDummy::ParserCommon::FileType() : File '%s' is of type 'ftHeader' (w/ ext.)."), filename.
wx_str());
107 for (
size_t i=0; i<source_ext.
GetCount(); ++i)
109 if (ext==source_ext[i])
112 log.
Printf(
wxT(
"ParserDummy::ParserCommon::FileType() : File '%s' is of type 'ftSource' (w/ ext.)."), filename.
wx_str());
119 log.
Printf(
wxT(
"ParserDummy::ParserCommon::FileType() : File '%s' is of type 'ftOther' (unknown ext)."), filename.
wx_str());
127 static bool cfg_read =
false;
128 static bool empty_ext =
true;
132 if (!cfg_read || force_refresh)
135 empty_ext = cfg->
ReadBool(
_T(
"/empty_ext"),
true);
136 wxString header_ext_str = cfg->
Read(
_T(
"/header_ext"),
_T(
"h,hpp,hxx,hh,h++,tcc,tpp,xpm"));
137 wxString source_ext_str = cfg->
Read(
_T(
"/source_ext"),
_T(
"c,cpp,cxx,cc,c++"));
156 const int pos = file.
Find(
_T(
'.'),
true);
161 if (empty_ext && ext.
IsEmpty())
164 for (
size_t i=0; i<header_ext.
GetCount(); ++i)
166 if (ext==header_ext[i])
170 for (
size_t i=0; i<source_ext.
GetCount(); ++i)
172 if (ext==source_ext[i])
178 #endif //CC_PARSER_TEST 203 return Reparse(filename, !isGlobal);
214 opts.parentIdxOfBuffer = -1;
215 opts.initLineOfBuffer = -1;
216 opts.bufferSkipBlocks =
false;
217 opts.bufferSkipOuterBlocks =
false;
220 opts.followLocalIncludes =
true;
221 opts.followGlobalIncludes =
true;
222 opts.wantPreprocessor =
true;
223 opts.parseComplexMacros =
true;
224 opts.platformCheck =
true;
226 opts.handleFunctions =
true;
227 opts.handleVars =
true;
228 opts.handleClasses =
true;
229 opts.handleEnums =
true;
230 opts.handleTypedefs =
true;
232 opts.storeDocumentation =
true;
234 opts.loader = loader;
242 bool success = pt->
Parse();
251 bool bufferSkipBlocks,
278 bool success = thread.
Parse();
290 if (base.
Last() == wxFILE_SEP_PATH)
294 TRACE(
_T(
"ParserBase::AddIncludeDir(): Directory %s does not exist?!"), base.
wx_str());
300 TRACE(
_T(
"ParserBase::AddIncludeDir(): Adding %s"), base.
wx_str());
331 FoundSet.
Add(fullname);
337 TRACE(
_T(
"ParserBase::FindFileInIncludeDirs(): Searching %s"), file.
wx_str());
338 TRACE(
_T(
"ParserBase::FindFileInIncludeDirs(): Found %lu"), static_cast<unsigned long>(FoundSet.
GetCount()));
384 size_t tokens_found = 0;
386 TRACE(
_T(
"Parser::FindTokensInFile() : Searching for file '%s' in tokens tree..."), filename.
wx_str());
393 for (TokenIdxSet::const_iterator it = tmpresult.begin(); it != tmpresult.end(); ++it)
399 tokens_found = result.size();
wxString AfterLast(wxUniChar ch) const
bool Parse()
Do the main job (syntax analysis) here.
wxString fileOfBuffer
which file the buffer belongs to, this usually happens when we parse a piece of the cbEditor and the ...
A parser threaded task, which can be assigned to the thread task pool, and run there.
bool followLocalIncludes
parse the file in #include "file" directive
void Delete(std::vector< T > &s)
ConfigManager * GetConfigManager(const wxString &name_space) const
static bool Exists(const wxString &dir)
static Manager * Get()
Use Manager::Get() to get a pointer to its instance Manager::Get() is guaranteed to never return an i...
friend class ParserThread
bool isTemp
this value is passed to the generated Token's m_IsTemp property
wxString FindFirstFileInIncludeDirs(const wxString &file)
ParserOptions m_Options
options for how the parser try to parse files
bool wxFileExists(const wxString &filename)
bool ReadBool(const wxString &name, bool defaultVal=false)
int Index(const wxString &sz, bool bCase=true, bool bFromEnd=false) const
DLLIMPORT bool NormalizePath(wxFileName &f, const wxString &base)
bool storeDocumentation
this will check for the platform of the project/target when adding include folders to the parser ...
virtual bool ParseFile(const wxString &filename, bool isGlobal, bool locked=false)
a container class to hold all the Tokens getting from parsing stage
int parentIdxOfBuffer
when parsing a function body, all the tokens are the children of the function token ...
wxArrayString FindFileInIncludeDirs(const wxString &file, bool firstonly=false)
it mimics what a compiler does to find an include header files, if the firstonly option is true...
EFileType FileType(const wxString &filename, bool force_refresh=false)
return a file type, which can be either header files or implementation files or other files ...
size_t AddItem(const wxString &s, T item, bool replaceexisting=false)
Adds an item to position defined by s and return the item number.
virtual bool Reparse(cb_unused const wxString &filename, cb_unused bool isLocal=true)
DLLIMPORT wxString UnixFilename(const wxString &filename, wxPathFormat format=wxPATH_NATIVE)
TokenTree * m_TempTokenTree
a temp Token tree hold some temporary tokens, e.g.
a symbol found in the parsed files, it can be many kinds, such as a variable, a class and so on...
wxString & RemoveLast(size_t n=1)
std::set< int, std::less< int > > TokenIdxSet
#define TRACE(format, args...)
size_t FindTokensInFile(const wxString &filename, TokenIdxSet &result, short int kindMask)
EFileType
the enum type of the file type
bool handleFunctions
whether to parse the functions
size_t FindTokensInFile(const wxString &filename, TokenIdxSet &result, short int kindMask)
find tokens belong to a specified file
TokenTree * m_TokenTree
each Parser class contains a TokenTree object which used to record tokens per project this tree will ...
wxString Read(const wxString &key, const wxString &defaultVal=wxEmptyString)
bool wantPreprocessor
case sensitive in MarkItemsByAI
bool wantPreprocessor
handle the #if like preprocessor directives, this value is passed to Tokenizer
#define CC_LOCKER_TRACK_TT_MTX_UNLOCK(M)
const wxStringCharType * wx_str() const
void AddIncludeDir(const wxString &dir)
add a directory to the Parser's include path database
bool parseComplexMacros
not used
wxString & Trim(bool fromRight=true)
bool storeDocumentation
should tokenizer detect and store doxygen documentation?
wxArrayString m_IncludeDirs
the include directories can be either three kinds below: 1, compiler's default search paths...
#define CC_LOCKER_TRACK_TT_MTX_LOCK(M)
bool HasMoreTokens() const
wxString GetPath(int flags=wxPATH_GET_VOLUME, wxPathFormat format=wxPATH_NATIVE) const
bool useBuffer
useBuffer specifies that we're not parsing a file, but a temporary buffer.
size_t Add(const wxString &str, size_t copies=1)
T GetItem(const wxString &s)
Gets the item at position defined by key string s.
int Find(wxUniChar ch, bool fromEnd=false) const
virtual TokenTree * GetTokenTree() const
bool followGlobalIncludes
parse the file in #include <file> directive
size_t ReserveFileForParsing(const wxString &filename, bool preliminary=false)
mark a file to be parsed.
wxString SubString(size_t from, size_t to) const
int initLineOfBuffer
since we are not parsing start from the first line of the file, this is the first line number of the ...
int Printf(const wxString &pszFormat,...)
SearchTree< wxString > m_GlobalIncludes
wxString -> wxString map
wxString GetFullPath(wxPathFormat format=wxPATH_NATIVE) const
bool bufferSkipBlocks
do we parse inside the {...} body
virtual bool ParseBuffer(const wxString &buffer, bool isLocal, bool bufferSkipBlocks=false, bool isTemp=false, const wxString &filename=wxEmptyString, int parentIdx=-1, int initLine=0)
wxString GetFullFileName(const wxString &src, const wxString &tgt, bool isGlobal)