src/format.cpp

changeset 138
a426c1039655
parent 137
73d057b030d0
child 141
68d60e2cfa76
equal deleted inserted replaced
137:73d057b030d0 138:a426c1039655
29 #include <cstdio> 29 #include <cstdio>
30 #include "main.h" 30 #include "main.h"
31 #include "format.h" 31 #include "format.h"
32 #include "lexer.h" 32 #include "lexer.h"
33 33
34 // _________________________________________________________________________________________________
34 // 35 //
35 // Throws an error while formatting the string 36 // Throws an error while formatting the string
36 // 37 //
37 static void formatError (String fmtstr, const String errdescribe, int pos) 38 static void formatError (String fmtstr, const String errdescribe, int pos)
38 { 39 {
45 46
46 errmsg += "^\n" + errdescribe; 47 errmsg += "^\n" + errdescribe;
47 throw std::logic_error (errmsg.stdString()); 48 throw std::logic_error (errmsg.stdString());
48 } 49 }
49 50
51 // _________________________________________________________________________________________________
50 // 52 //
51 // Main formatter algorithm function. Processes @fmtstr with @args and returns 53 // Main formatter algorithm function. Processes @fmtstr with @args and returns
52 // the result. 54 // the result.
53 // 55 //
54 String formatArgs (const String& fmtstr, const std::vector<String>& args) 56 String formatArgs (const String& fmtstr, const std::vector<String>& args)
102 } 104 }
103 105
104 return fmt; 106 return fmt;
105 } 107 }
106 108
109 // _________________________________________________________________________________________________
107 // 110 //
108 // Throws a runtime error with the message @msg. If a lexer is active, its 111 // Throws a runtime error with the message @msg. If a lexer is active, its
109 // position is printed as well. 112 // position is printed as well.
110 // 113 //
111 void error (const String& msg) 114 void error (const String& msg)

mercurial