MCPcopy Create free account
hub / github.com/ChaiScript/ChaiScript / main

Function main

src/main.cpp:268–405  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

266}
267
268int main(int argc, char *argv[])
269{
270
271 // Disable deprecation warning for getenv call.
272#ifdef CHAISCRIPT_MSVC
273#pragma warning(push)
274#pragma warning(disable : 4996)
275#endif
276
277 const char *usepath = getenv("CHAI_USE_PATH");
278 const char *modulepath = getenv("CHAI_MODULE_PATH");
279
280#ifdef CHAISCRIPT_MSVC
281#pragma warning(pop)
282#endif
283
284 std::vector<std::string> usepaths;
285 usepaths.push_back("");
286 if (usepath != nullptr)
287 {
288 usepaths.push_back(usepath);
289 }
290
291 std::vector<std::string> modulepaths;
292 std::vector<std::string> searchpaths = default_search_paths();
293 modulepaths.insert(modulepaths.end(), searchpaths.begin(), searchpaths.end());
294 modulepaths.push_back("");
295 if (modulepath != nullptr)
296 {
297 modulepaths.push_back(modulepath);
298 }
299
300 chaiscript::ChaiScript_Basic chai(create_chaiscript_stdlib(),create_chaiscript_parser(),modulepaths,usepaths);
301
302 chai.add(chaiscript::fun(&myexit), "exit");
303 chai.add(chaiscript::fun(&myexit), "quit");
304 chai.add(chaiscript::fun(&help), "help");
305 chai.add(chaiscript::fun(&throws_exception), "throws_exception");
306 chai.add(chaiscript::fun(&get_eval_error), "get_eval_error");
307 chai.add(chaiscript::fun(&now), "now");
308
309 bool eval_error_ok = false;
310 bool boxed_exception_ok = false;
311 bool any_exception_ok = false;
312
313 for (int i = 0; i < argc; ++i) {
314 if ( i == 0 && argc > 1 ) {
315 ++i;
316 }
317
318 std::string arg( i != 0 ? argv[i] : "--interactive" );
319
320 enum { eInteractive
321 , eCommand
322 , eFile
323 } mode = eCommand ;
324
325 if ( arg == "-c" || arg == "--command" ) {

Callers

nothing calls this directly

Calls 14

create_chaiscript_stdlibFunction · 0.85
create_chaiscript_parserFunction · 0.85
funFunction · 0.85
eval_fileMethod · 0.80
default_search_pathsFunction · 0.70
interactiveFunction · 0.70
endMethod · 0.45
beginMethod · 0.45
addMethod · 0.45
findMethod · 0.45
evalMethod · 0.45
pretty_printMethod · 0.45

Tested by

no test coverage detected