src/format.cc

changeset 79
2425fa6a4f21
parent 75
bf8c57437231
child 81
071715c17296
equal deleted inserted replaced
78:e6d7e32e6481 79:2425fa6a4f21
29 */ 29 */
30 30
31 #include <cstdio> 31 #include <cstdio>
32 #include "main.h" 32 #include "main.h"
33 #include "format.h" 33 #include "format.h"
34 #include "lexer.h"
34 35
35 static void draw_pos (const string& fmt, int pos) 36 static void draw_pos (const string& fmt, int pos)
36 { 37 {
37 string rep (fmt); 38 string rep (fmt);
38 rep.replace ("\n", "↵"); 39 rep.replace ("\n", "↵");
120 void print_args (FILE* fp, const list<format_arg>& args) 121 void print_args (FILE* fp, const list<format_arg>& args)
121 { 122 {
122 string out = format_args (args); 123 string out = format_args (args);
123 fprintf (fp, "%s", out.chars()); 124 fprintf (fp, "%s", out.chars());
124 } 125 }
126
127 void do_error (string msg)
128 {
129 lexer* lx = lexer::get_main_lexer();
130 string fileinfo;
131
132 if (lx != null && lx->has_valid_token())
133 {
134 lexer::token* tk = lx->get_token();
135 fileinfo = format ("%1:%2:%3: ", tk->file, tk->line, tk->column);
136 }
137
138 throw script_error (fileinfo + msg);
139 }

mercurial