File tree Expand file tree Collapse file tree 3 files changed +11
-3
lines changed Expand file tree Collapse file tree 3 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ int main(int argc, char **argv)
19
19
const char *filename = nullptr ;
20
20
bool use_istream = false ;
21
21
bool fail_on_error = false ;
22
+ bool linenrs = false ;
22
23
23
24
// Settings..
24
25
simplecpp::DUI dui;
@@ -75,6 +76,10 @@ int main(int argc, char **argv)
75
76
fail_on_error = true ;
76
77
found = true ;
77
78
break ;
79
+ case ' l' :
80
+ linenrs = true ;
81
+ found = true ;
82
+ break ;
78
83
}
79
84
if (!found) {
80
85
std::cout << " error: option '" << arg << " ' is unknown." << std::endl;
@@ -107,6 +112,7 @@ int main(int argc, char **argv)
107
112
std::cout << " -q Quiet mode (no output)." << std::endl;
108
113
std::cout << " -is Use std::istream interface." << std::endl;
109
114
std::cout << " -e Output errors only." << std::endl;
115
+ std::cout << " -l Print lines numbers." << std::endl;
110
116
std::exit (0 );
111
117
}
112
118
@@ -137,7 +143,7 @@ int main(int argc, char **argv)
137
143
// Output
138
144
if (!quiet) {
139
145
if (!error_only)
140
- std::cout << outputTokens.stringify () << std::endl;
146
+ std::cout << outputTokens.stringify (linenrs ) << std::endl;
141
147
142
148
for (const simplecpp::Output &output : outputList) {
143
149
std::cerr << output.location .file () << ' :' << output.location .line << " : " ;
Original file line number Diff line number Diff line change @@ -567,7 +567,7 @@ void simplecpp::TokenList::dump() const
567
567
std::cout << stringify () << std::endl;
568
568
}
569
569
570
- std::string simplecpp::TokenList::stringify () const
570
+ std::string simplecpp::TokenList::stringify (bool linenrs ) const
571
571
{
572
572
std::ostringstream ret;
573
573
Location loc (files);
@@ -580,6 +580,8 @@ std::string simplecpp::TokenList::stringify() const
580
580
while (tok->location .line > loc.line ) {
581
581
ret << ' \n ' ;
582
582
loc.line ++;
583
+ if (linenrs)
584
+ ret << loc.line << " : " ;
583
585
}
584
586
585
587
if (sameline (tok->previous , tok))
Original file line number Diff line number Diff line change @@ -222,7 +222,7 @@ namespace simplecpp {
222
222
void push_back (Token *tok);
223
223
224
224
void dump () const ;
225
- std::string stringify () const ;
225
+ std::string stringify (bool linenrs = false ) const ;
226
226
227
227
void readfile (Stream &stream, const std::string &filename=std::string(), OutputList *outputList = nullptr);
228
228
void constFold ();
You can’t perform that action at this time.
0 commit comments