]> granicus.if.org Git - re2c/commitdiff
Reduce 'file_info' usage (in order to get rid of 'stream_lc.h').
authorUlya Trofimovich <skvadrik@gmail.com>
Thu, 26 Feb 2015 13:23:02 +0000 (13:23 +0000)
committerUlya Trofimovich <skvadrik@gmail.com>
Thu, 26 Feb 2015 13:23:02 +0000 (13:23 +0000)
re2c/bootstrap/parser.cc
re2c/bootstrap/scanner.cc
re2c/code.cc
re2c/output.cc
re2c/output.h
re2c/parser.y
re2c/re.h
re2c/scanner.re

index 7e61a5c6f8b7900300dc59e043a867da25d152f9..304c57bee42d9866479b8ccaacd03546b59e2ead 100644 (file)
@@ -2233,7 +2233,7 @@ void parse(Scanner& i, Output & o)
        in = &i;
 
        output_version_time (o.source);
-       o.source << sourceFileInfo;
+       output_line_info (o.source.fragment (), sourceFileInfo.ln->get_line (), sourceFileInfo.fname.c_str ());
        output_version_time (o.header);
 
        Enc encodingOld = encoding;
@@ -2413,7 +2413,7 @@ void parse(Scanner& i, Output & o)
                                }
                        }
                }
-               o.source << sourceFileInfo;
+               output_line_info (o.source.fragment (), sourceFileInfo.ln->get_line (), sourceFileInfo.fname.c_str ());
                /* restore original char handling mode*/
                encoding = encodingOld;
        }
index 47205749c90a9e1c06022c31ce0e0b396870a479..3d53362aae3b34da91bbcfb8173dff348e51c24e 100644 (file)
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.14.1.dev on Tue Feb 24 15:15:39 2015 */
+/* Generated by re2c 0.14.1.dev on Thu Feb 26 12:59:58 2015*/
 #include <stdlib.h>
 #include <string.h>
 #include <iostream>
@@ -384,7 +384,7 @@ yy74:
                                                out << "\n";
                                                out.insert_types ();
                                                out << "\n";
-                                               out << sourceFileInfo;
+                                               output_line_info (out.fragment (), sourceFileInfo.ln->get_line (), sourceFileInfo.fname.c_str ());
                                        }
                                        goto echo;
                                }
@@ -399,7 +399,8 @@ yy85:
                                        {
                                                if (ignore_cnt)
                                                {
-                                                       out << "\n" << sourceFileInfo;
+                                                       out << "\n";
+                                                       output_line_info (out.fragment (), sourceFileInfo.ln->get_line (), sourceFileInfo.fname.c_str ());
                                                }
                                                ignore_eoc = false;
                                                ignore_cnt = 0;
@@ -422,7 +423,7 @@ yy87:
                                        {
                                                if (ignore_cnt)
                                                {
-                                                       out << sourceFileInfo;
+                                                       output_line_info (out.fragment (), sourceFileInfo.ln->get_line (), sourceFileInfo.fname.c_str ());
                                                }
                                                ignore_eoc = false;
                                                ignore_cnt = 0;
index 2414f7bd6034dfc9faf102f7c9dc84161d63db82..e7179408cac438478c6f7daafc294699194c5fca 100644 (file)
@@ -700,14 +700,12 @@ void Rule::emit(Output & output, uint ind, bool &, const std::string& condName)
                genSetCondition(o, ind, rule->code->newcond);
        }
 
-       RuleLine rl(*rule);
-
        if (!yySetupRule.empty() && !rule->code->autogen)
        {
                o << indent(ind) << yySetupRule << "\n";
        }
 
-       o << file_info(rule->code->source, &rl);
+       output_line_info (o.fragment (), rule->code->line, rule->code->source.c_str ());
        o << indent(ind);
        if (rule->code->autogen)
        {
index 5e9afc21109468efa9e6c590eeacb944e5c8be60..3c81f2e7f7154cb9cc73147ae61c7d5cbbed9ba5 100644 (file)
@@ -7,15 +7,6 @@
 namespace re2c
 {
 
-OutputFragment & operator << (OutputFragment & o, const file_info & i)
-{
-       if (i.ln && !iFlag)
-       {
-               o << "#line " << i.ln->get_line () << " \"" << i.fname << "\"\n";
-       }
-       return o;
-}
-
 uint OutputFragment::count_lines ()
 {
        uint lines = 0;
@@ -111,12 +102,6 @@ OutputFile & operator << (OutputFile & u, const char * s)
        return u;
 }
 
-OutputFile & operator << (OutputFile & u, const file_info & i)
-{
-       u.fragment () << i;
-       return u;
-}
-
 OutputFile & operator << (OutputFile & u, const Str & s)
 {
        u.fragment () << s;
index 3652dfc0f9dbb3b0f5f5e1b6d1ebce4c4c424121..b4ad27a6c9e0db2b53e828ac2facdc1dde0f67fb 100644 (file)
@@ -10,7 +10,6 @@
 namespace re2c
 {
 
-struct file_info;
 struct Str;
 
 struct Setw
@@ -54,8 +53,6 @@ struct OutputFragment : public std::ostringstream
        uint count_lines ();
 };
 
-OutputFragment & operator << (OutputFragment & f, const file_info & info);
-
 struct OutputBlock
 {
        std::vector<OutputFragment *> fragments;
@@ -90,7 +87,6 @@ struct OutputFile
        friend OutputFile & operator << (OutputFile & o, uint n);
        friend OutputFile & operator << (OutputFile & o, const std::string & s);
        friend OutputFile & operator << (OutputFile & o, const char * s);
-       friend OutputFile & operator << (OutputFile & o, const file_info & i);
        friend OutputFile & operator << (OutputFile & o, const Str & s);
        friend OutputFile & operator << (OutputFile & o, const Setw & s);
 
index 6b8752b5a5bcc3f49c316a5a457e7d0f00271db7..4c36690d597d0badbd06c84abe2b1ef56c8029ee 100644 (file)
@@ -513,7 +513,7 @@ void parse(Scanner& i, Output & o)
        in = &i;
 
        output_version_time (o.source);
-       o.source << sourceFileInfo;
+       output_line_info (o.source.fragment (), sourceFileInfo.ln->get_line (), sourceFileInfo.fname.c_str ());
        output_version_time (o.header);
 
        Enc encodingOld = encoding;
@@ -693,7 +693,7 @@ void parse(Scanner& i, Output & o)
                                }
                        }
                }
-               o.source << sourceFileInfo;
+               output_line_info (o.source.fragment (), sourceFileInfo.ln->get_line (), sourceFileInfo.fname.c_str ());
                /* restore original char handling mode*/
                encoding = encodingOld;
        }
index 068ff69ef85d0fb9b2d4799b37784a61a19c3744..d758af1df1e1916a7f35cfa2c316ad1cd6514790 100644 (file)
--- a/re2c/re.h
+++ b/re2c/re.h
@@ -216,23 +216,6 @@ private:
 #endif
 };
 
-class RuleLine: public line_number
-{
-public:
-
-       RuleLine(const RuleOp& _op)
-               : op(_op)
-       {
-       }
-
-       uint get_line() const
-       {
-               return op.code->line;
-       }
-
-       const RuleOp& op;
-};
-
 RegExp *doAlt(RegExp*, RegExp*);
 RegExp *mkAlt(RegExp*, RegExp*);
 
index 805292d03efea25fc114b690d31a2862ee39bec6..619208a004b76d996a295d595127d2f11001e5f6 100644 (file)
@@ -130,7 +130,7 @@ echo:
                                                out << "\n";
                                                out.insert_types ();
                                                out << "\n";
-                                               out << sourceFileInfo;
+                                               output_line_info (out.fragment (), sourceFileInfo.ln->get_line (), sourceFileInfo.fname.c_str ());
                                        }
                                        goto echo;
                                }
@@ -140,7 +140,7 @@ echo:
                                        {
                                                if (ignore_cnt)
                                                {
-                                                       out << sourceFileInfo;
+                                                       output_line_info (out.fragment (), sourceFileInfo.ln->get_line (), sourceFileInfo.fname.c_str ());
                                                }
                                                ignore_eoc = false;
                                                ignore_cnt = 0;
@@ -157,7 +157,8 @@ echo:
                                        {
                                                if (ignore_cnt)
                                                {
-                                                       out << "\n" << sourceFileInfo;
+                                                       out << "\n";
+                                                       output_line_info (out.fragment (), sourceFileInfo.ln->get_line (), sourceFileInfo.fname.c_str ());
                                                }
                                                ignore_eoc = false;
                                                ignore_cnt = 0;