From: helly Date: Thu, 21 Jul 2005 16:25:24 +0000 (+0000) Subject: - Add -i switch to avoid generating #line information. X-Git-Tag: 0.13.6~611 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=28543b0c754d1a3164fdd2a3d4d21132424c87a6;p=re2c - Add -i switch to avoid generating #line information. --- diff --git a/CHANGELOG b/CHANGELOG index d627efbb..84afb9c1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,6 @@ Version 0.9.10 (????-??-??) --------------------------- +- Add -i switch to avoid generating #line information. Version 0.9.9 (2005-07-21) -------------------------- diff --git a/code.cc b/code.cc index 1dc028e2..3556cf88 100644 --- a/code.cc +++ b/code.cc @@ -452,10 +452,13 @@ void Rule::emit(std::ostream &o, bool &readCh) o << rule->code->text; // not sure if we need this or not. oline += std::count(rule->code->text, rule->code->text + ::strlen(rule->code->text), '\n'); o << "\n"; - ++oline; - o << "#line " << oline++ << " \"" << outputFileName << "\"\n"; - // o << "\n#line " << rule->code->line - // << "\n\t" << rule->code->text << "\n"; + if (!iFlag) + { + ++oline; + o << "#line " << oline++ << " \"" << outputFileName << "\"\n"; + // o << "\n#line " << rule->code->line + // << "\n\t" << rule->code->text << "\n"; + } } void doLinear(std::ostream &o, uint i, Span *s, uint n, State *from, State *next, bool &readCh) @@ -1220,7 +1223,11 @@ void DFA::emit(std::ostream &o) oline = nOrgOline; oline++; - o << "\n#line " << oline++ << " \"" << outputFileName << "\"\n"; + o << "\n"; + if (!iFlag) + { + o << "#line " << oline++ << " \"" << outputFileName << "\"\n"; + } if ( hasFillLabels == false ) { diff --git a/globals.h b/globals.h index b868b1b7..23365503 100644 --- a/globals.h +++ b/globals.h @@ -36,6 +36,7 @@ extern char *outputFileName; extern bool sFlag; extern bool bFlag; extern bool dFlag; +extern bool iFlag; extern bool bUsedYYAccept; extern unsigned int oline; extern uint maxFill; diff --git a/main.cc b/main.cc index 026cca5e..6e585945 100644 --- a/main.cc +++ b/main.cc @@ -21,7 +21,7 @@ char *outputFileName = 0; bool sFlag = false; bool bFlag = false; bool dFlag = false; -bool qFlag = false; +bool iFlag = false; bool bUsedYYAccept = false; unsigned int oline = 1; uint maxFill = 1; @@ -42,6 +42,7 @@ static const mbo_opt_struct OPTIONS[] = mbo_opt_struct('e', 0, "ecb"), mbo_opt_struct('f', 0, "storable-state"), mbo_opt_struct('h', 0, "help"), + mbo_opt_struct('i', 0, "debug-info"), mbo_opt_struct('o', 1, "output"), mbo_opt_struct('s', 0, "nested-ifs"), mbo_opt_struct('v', 0, "version"), @@ -74,6 +75,8 @@ static void usage() " about the current position and in which state the\n" " parser is.\n" "\n" + "-i --no-debug-info Do not generate '#line' info (usefull for versioning).\n" + "\n" "-v --version Show version information.\n" "-V --vernum Show version as one number.\n" ; @@ -121,6 +124,10 @@ int main(int argc, char *argv[]) vFillIndexes = 0; break; + case 'i': + iFlag = true; + break; + case 'o': outputFileName = opt_arg; break; diff --git a/parser.y b/parser.y index 31d06b33..761fd9d5 100644 --- a/parser.y +++ b/parser.y @@ -178,6 +178,10 @@ void line_source(unsigned int line, std::ostream& o) char * fnamebuf; char * token; + if (iFlag) + { + return; + } o << "#line " << line << " \""; if( fileName != NULL ) { fnamebuf = strdup( fileName ); diff --git a/re2c.1.in b/re2c.1.in index 8f32750f..cd3cfaa9 100644 --- a/re2c.1.in +++ b/re2c.1.in @@ -7,6 +7,9 @@ .ds rx regular expression .ds lx \fIl\fP-expression \"$Log$ +\"Revision 1.23 2005/07/21 16:25:24 helly +\"- Add -i switch to avoid generating #line information. +\" \"Revision 1.22 2005/07/10 14:16:26 helly \"- Update \" @@ -196,6 +199,11 @@ parser issues and states. If you use this switch you need to define a macro \fIvoid YYDEBUG(int state, char current)\fP. The first parameter receives the state or -1 and the second parameter receives the input at the current cursor. .TP +\fB-d\fP +Do not output #line information. This is usefull when you want use a CMS tool +with the re2c output which you might want if you do not require your users to +have re2c themselves when building from your source. +.TP \fB-h\fP \fB-?\fP Invoke a short help.