From: Ulya Trofimovich Date: Thu, 26 Feb 2015 13:23:02 +0000 (+0000) Subject: Reduce 'file_info' usage (in order to get rid of 'stream_lc.h'). X-Git-Tag: 0.15~376 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0e2ce85feb73c9de264f10c850ad5d5dd3551ec9;p=re2c Reduce 'file_info' usage (in order to get rid of 'stream_lc.h'). --- diff --git a/re2c/bootstrap/parser.cc b/re2c/bootstrap/parser.cc index 7e61a5c6..304c57be 100644 --- a/re2c/bootstrap/parser.cc +++ b/re2c/bootstrap/parser.cc @@ -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; } diff --git a/re2c/bootstrap/scanner.cc b/re2c/bootstrap/scanner.cc index 47205749..3d53362a 100644 --- a/re2c/bootstrap/scanner.cc +++ b/re2c/bootstrap/scanner.cc @@ -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 #include #include @@ -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; diff --git a/re2c/code.cc b/re2c/code.cc index 2414f7bd..e7179408 100644 --- a/re2c/code.cc +++ b/re2c/code.cc @@ -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) { diff --git a/re2c/output.cc b/re2c/output.cc index 5e9afc21..3c81f2e7 100644 --- a/re2c/output.cc +++ b/re2c/output.cc @@ -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; diff --git a/re2c/output.h b/re2c/output.h index 3652dfc0..b4ad27a6 100644 --- a/re2c/output.h +++ b/re2c/output.h @@ -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 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); diff --git a/re2c/parser.y b/re2c/parser.y index 6b8752b5..4c36690d 100644 --- a/re2c/parser.y +++ b/re2c/parser.y @@ -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; } diff --git a/re2c/re.h b/re2c/re.h index 068ff69e..d758af1d 100644 --- 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*); diff --git a/re2c/scanner.re b/re2c/scanner.re index 805292d0..619208a0 100644 --- a/re2c/scanner.re +++ b/re2c/scanner.re @@ -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;