]> granicus.if.org Git - re2c/commitdiff
- Add -i switch to avoid generating #line information.
authorhelly <helly@642ea486-5414-0410-9d7f-a0204ed87703>
Thu, 21 Jul 2005 16:25:24 +0000 (16:25 +0000)
committerhelly <helly@642ea486-5414-0410-9d7f-a0204ed87703>
Thu, 21 Jul 2005 16:25:24 +0000 (16:25 +0000)
CHANGELOG
code.cc
globals.h
main.cc
parser.y
re2c.1.in

index d627efbb38a28d3ec85b1eced68a58a831862d65..84afb9c116a4c1340437671a1d8f428c5beadd5c 100644 (file)
--- 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 1dc028e25feb5e576fe15367bf841cac96be88ed..3556cf88172055ad6c177f841ebbdeafa7b7ac70 100644 (file)
--- 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 )
        {
index b868b1b7920d0cbb799513e14b34a915b60a66df..23365503c40f8eff1478ac81abc8be3f028a0f31 100644 (file)
--- 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 026cca5e8e82b81aea5ef96ea6d5cd1c47b2df7c..6e58594532a9424d31c9dac55dc6c0e8945c1f53 100644 (file)
--- 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;
index 31d06b3335da6fc136e17ac6487353e236cad71a..761fd9d55ed90865b61369be5ab996fbf5c67b76 100644 (file)
--- 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 );
index 8f32750f453db7581939a0ea6c196aed467cd499..cd3cfaa9aee90631bff7bb7d6689210fd85963ee 100644 (file)
--- 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.