33 #define DEBUG_EXTENT_STREAMS 1
41 using std::setiosflags;
42 using std::resetiosflags;
101 static string retval;
108 retval=retval+
parser->LT(i)->getText();
116 SetWordType *resync_token_class,
117 ANTLRTokenPtr& resync_token)
128 string resync_text=
"...";
130 string string1=
parser->LT(1)->getText();
131 int line1=
parser->LT(1)->getLine();
135 int resynchronising=1;
136 while(resynchronising)
138 parser->consumeUntil(resync_token_class);
140 (
MY_TOK(
parser->LT(1))->getNestingLevel() > initial_nesting) &&
150 string2=
parser->LT(1)->getText();
151 line2=
parser->LT(1)->getLine();
158 resync_token=
parser->LT(1);
160 parser->set_el(
parser->LT(1)->getType(),resync_token_class) &&
161 (
MY_TOK(
parser->LT(1))->getNestingLevel() == initial_nesting)
164 string2=
parser->LT(1)->getText();
165 line2=
parser->LT(1)->getLine();
167 resync_text+=
parser->LT(1)->getText();
169 resync_token=
parser->LT(1);
170 resync_token->setText(resync_text.c_str());
174 cerr <<
"Unrecognized section from "
175 << string1.c_str() <<
" on line " << line1 <<
" to "
176 << string2.c_str() <<
" on line " << line2 << endl
177 <<
"=====ignored section begins=====" << endl
178 << resync_text.c_str() << endl
179 <<
"===== ignored section ends =====" << endl;
216 bool bIgnoreScope=
true;
222 else if(baseScope.size()>0 && name.size()>0)
224 retval=baseScope+
"::"+
name;
228 retval=baseScope+
name;
235 : theFilename(filename)
236 , pendingLexicalCounts(static_cast<int>(
tcLAST),0)
237 , flag(static_cast<int>(
psfLAST)+1,
'?')
262 return int(
flag[psf]);
289 const string& description,
const string&
flags,
290 UseType ut,
bool allocate_lexcounts)
297 int lexical_counts_for_this_extent[
tcLAST];
300 lexical_counts_for_this_extent[i]=0;
303 if(allocate_lexcounts==
true)
305 LineLexicalCountMatrix::iterator extentStartIter =
307 LineLexicalCountMatrix::iterator extentEndIter =
309 LineLexicalCountMatrix::iterator llcmIter;
310 for(llcmIter=extentStartIter;
311 llcmIter!=extentEndIter;
318 lexical_counts_for_this_extent[i]+=(*llcmIter).second[i];
329 ostringstream lexcount_str;
331 lexcount_str <<
"LOC:" << lexical_counts_for_this_extent[
tcCODELINES]
332 <<
" COM:" << lexical_counts_for_this_extent[
tcCOMLINES]
333 <<
" MVG:" << lexical_counts_for_this_extent[
tcMCCABES_VG]
336 os.
Insert(lexcount_str.str().c_str());
350 const string& moduleName,
351 const string& moduleType,
352 const string& description,
357 if(moduleName.size()>0)
360 module_line.
Insert(moduleName);
361 module_line.
Insert(moduleType);
363 description,
flags(),ut,
true);
369 const string& returnType,
370 const string& moduleName,
371 const string& memberName,
372 const string& paramList,
373 const string& description,
379 if(memberName.size()>0)
384 string mappedModuleName = moduleName;
385 if(mappedModuleName.size()==0)
387 mappedModuleName =
"anonymous";
391 function_line.
Insert(mappedModuleName);
392 function_line.
Insert(memberName);
393 function_line.
Insert(returnType);
394 function_line.
Insert(paramList);
396 string baseFlags=
flags();
400 description,baseFlags,ut,
true);
406 const string& clientName,
407 const string& memberName,
408 const string& serverName,
409 const string& description,
424 if(clientName.size()>0 && serverName.size()>0)
426 userel_line.
Insert(clientName);
427 userel_line.
Insert(memberName);
428 userel_line.
Insert(serverName);
433 bool record_lexcounts=
false;
438 record_lexcounts=
true;
441 record_lexcounts=
false;
444 string baseFlags=
flags();
447 description,baseFlags,ut,record_lexcounts);
453 const string& description)
466 std::setw(6) << tok->getLine()
467 << std::setw(4) << (int)tok->getType()
468 << std::setiosflags(ios::left)
469 << std::resetiosflags(ios::right)
470 << std::setw(20) << tok->getText()
482 const char *dir_indic,
484 ANTLRAbstractToken *tok)
486 static int trace_depth=0;
490 setw(trace_depth*4+1) <<
"" << dir_indic
491 <<
"?" << rulename << endl);
495 trace_depth=((
ANTLRToken*) tok)->getNestingLevel();
497 setw(trace_depth*4)<<
"" << dir_indic << rulename << endl);
502 const char *rulename,
int guessing,
503 ANTLRAbstractToken *tok)
517 rectrace(rulename,
"-> ",guessing,tok);
522 ANTLRAbstractToken *tok)
530 cerr <<
"ParseUtility::traceout negative stack depth - "
531 <<
"exiting from rule " << rulename
532 <<
" at " << tok->getText() <<
" on line " << tok->getLine()
537 cerr <<
"ParseStore::traceout rule name mismatch - "
546 rectrace(rulename,
"<- ",guessing,tok);
550 _ANTLRTokenPtr tok, ANTLRChar *egroup, SetWordType *eset,
556 cerr << filename <<
'(' << tok->getLine() <<
"):"
557 <<
" syntax error at token " << tok->getText() << endl;
561 cerr << filename <<
"(0): syntax error at null token" << endl;
575 cerr <<
"Parser context:" << endl;
596 LineLexicalCountMatrix::value_type
599 for(
int i=0; i<
tcLAST; i++)
istream & operator>>(istream &is, AugmentedBool &ab)
static void rectrace(const char *rulename, const char *dir_indic, int guessing, ANTLRAbstractToken *tok)
void insert_enum(ostream &os, int e)
std::vector< int > LexicalCountArray
bool Insert(const string &s)
static void toktrace(ANTLRAbstractToken *tok)
LineLexicalCountMatrix lineLexicalCounts
LexicalCountArray pendingLexicalCounts
string scopeCombine(const string &baseScope, const string &name)
void extract_enum(istream &is, int &e)
void add_rejected_extent(CCCC_Item &rejected_data_line)
ParseUtility(ANTLRParser *parser)
ANTLR_Assisted_Parser * parser
void resynchronize(int initial_nesting, SetWordType *resync_token_class, ANTLRTokenPtr &resync_token)
void record_module_extent(int startLine, int endLine, const string &moduleName, const string &moduleType, const string &description, UseType ut)
void add_module(CCCC_Item &module_data_line)
void traceout(const char *rulename, int guessing, ANTLRAbstractToken *tok)
static string stack_rules[MAX_STACK_DEPTH]
int get_flag(PSFlag) const
string name(int level) const
static ParseStore * currentInstance()
ostream & operator<<(ostream &os, AugmentedBool ab)
string lookahead_text(int n)
void set_flag(PSFlag, int)
void add_member(CCCC_Item &member_data_line)
void insert_extent(CCCC_Item &, int, int, const string &, const string &, UseType, bool allocate_lexcounts)
#define RELEASE_STRSTREAM(X)
static ParseUtility * theCurrentInstance
ParseStore(const string &filename)
void tracein(const char *rulename, int guessing, ANTLRAbstractToken *tok)
void record_other_extent(int startLine, int endLine, const string &description)
void record_function_extent(int startLine, int endLine, const string &returnType, const string &moduleName, const string &memberName, const string ¶mList, const string &description, Visibility visibility, UseType ut)
void record_userel_extent(int startLine, int endLine, const string &clientName, const string &memberName, const string &serverName, const string &description, Visibility visibility, UseType ut)
#define MAKE_STRSTREAM(X)
void add_userel(CCCC_Item &use_data_line)
#define DbgMsg(DF, OS, X)
static int stack_tokenline[MAX_STACK_DEPTH]
static ParseStore * theCurrentInstance
Visibility get_visibility()
static string stack_tokentext[MAX_STACK_DEPTH]
void syn(_ANTLRTokenPtr tok, ANTLRChar *egroup, SetWordType *eset, ANTLRTokenType etok, int k)