]>
git.saurik.com Git - wxWidgets.git/blob - utils/HelpGen/src/cjparser.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Implementation of C++/Java parser
4 // compatible with SourceParserBase interface
5 // Author: Aleksandras Gluchovas
9 // Copyright: (c) Aleskandars Gluchovas
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
13 #ifndef __CJPARSESR_G__
14 #define __CJPARSESR_G__
16 #include "srcparser.h"
28 // class parses given "memory-resident" Java or C++ source code
29 // and captures information about classes/attrubutes/methods/
30 // arguments/etc into structures. Conforms with SourceParserBase
31 // interface requirements.
33 class CJSourceParser
: public SourceParserBase
36 // begining of the full-text area of the source file
39 // points to first character after the end
40 // of teh full-text area
43 // current "privacy level"
46 // current parsing position int full-text area
49 // about the current class
54 // context data for which is currently being collected
57 int mCurCtxType
; // type of the current context
64 void AttachComments( spContext
& ctx
, char* cur
);
65 void ParseKeyword( char*& cur
);
66 bool ParseNameAndRetVal( char*& cur
, bool& isAMacro
);
67 bool ParseArguments( char*& cur
);
68 void ParseMemberVar( char*& cur
);
69 void SkipFunction( char*& cur
);
70 void SkipFunctionBody( char*& cur
);
71 bool CheckVisibilty( char*& cur
);
73 void AddClassNode( char*& cur
);
74 void AddMacroNode( char*& cur
);
75 void AddEnumNode( char*& cur
);
76 void AddTypeDefNode( char*& cur
);
78 void DumpOperationInfo( spOperation
& info
, const wxString
& tab
, wxSTD ostream
& os
);
79 void DumpClassHeader( spClass
& info
, wxSTD ostream
& os
);
80 void DumpClassBody( spClass
& info
, wxSTD ostream
& os
);
84 // NOTE:: discarding of macros or comments improves performance and
85 // decreases memory usage
87 CJSourceParser(bool collectCommnets
= 1,
88 bool collectMacros
= 1);
90 // returns the root-node of the created context tree
91 // (user is responsible for releasing it from the heep)
92 // "end" should point to the last (character + 1) of the
95 virtual spFile
* Parse( char* start
, char* end
);
98 // inline'ed helpers used (just info):
100 static inline void skip_to_eol( char*& cur );
101 static inline void skip_eol( char*& cur );
102 static inline bool skip_to_next_comment_in_the_line( char*& cur );
103 static void skip_to_prev_line( char*& cur );
104 static inline void skip_comments( char*& cur );
105 static inline void clear_commets_queue();
106 static inline void skip_quoted_string( char*& cur );
107 static inline bool get_next_token( char*& cur );
108 static inline void skip_preprocessor_dir( char*& cur );
109 static void skip_token( char*& cur );
110 static inline size_t get_token_len( char* tok );
111 static inline bool cmp_tokens( char* tok1, char* tok2 );
112 static inline bool cmp_tokens_fast( char* tok1, char* tok2, size_t len );
113 static inline void skip_tempalate_statement( char*& cur );
114 static inline void skip_statement( char*& cur );
115 static inline void skip_token_back( char*& cur );
116 static inline void skip_next_token_back( char*& cur );
117 static wxString get_token_str( char* cur );
118 static size_t skip_block( char*& cur );
119 static inline bool skip_imp_block( char*& cur );
120 static bool is_class_token( char*& cur );
121 inline static bool is_forward_decl( char* cur );
122 inline static bool is_function( char* cur, bool& isAMacro );
123 static inline void skip_scope_block( char*& cur );
124 static void arrange_indirection_tokens_between( wxString& type, wxString& identifier );
125 static bool is_keyword( char* cur );
126 static inline void get_string_between( char* start, char* end, wxString* pStr );
127 static char* set_comment_text( wxString& text, char* start );