MCPcopy Create free account
hub / github.com/BehaviorTree/BehaviorTree.CPP / ParseScript

Function ParseScript

src/script_parser.cpp:432–460  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

430//--- Public API ---
431
432Expected<ScriptFunction> ParseScript(const std::string& script)
433{
434 try
435 {
436 auto exprs = Scripting::parseStatements(script);
437 if(exprs.empty())
438 {
439 return nonstd::make_unexpected("Empty Script");
440 }
441 return [exprs = std::move(exprs), script](Ast::Environment& env) {
442 try
443 {
444 for(size_t i = 0; i < exprs.size() - 1; ++i)
445 {
446 exprs[i]->evaluate(env);
447 }
448 return exprs.back()->evaluate(env);
449 }
450 catch(RuntimeError& err)
451 {
452 throw RuntimeError(StrCat("Error in script [", script, "]\n", err.what()));
453 }
454 };
455 }
456 catch(RuntimeError& err)
457 {
458 return nonstd::make_unexpected(err.what());
459 }
460}
461
462Expected<Any> ParseScriptAndExecute(Ast::Environment& env, const std::string& script)
463{

Callers 7

instantiateTreeNodeMethod · 0.85
ParseScriptAndExecuteFunction · 0.85
TestNodeMethod · 0.85
loadExecutorMethod · 0.85
loadExecutorMethod · 0.85
loadExecutorMethod · 0.85
LLVMFuzzerTestOneInputFunction · 0.85

Calls 9

parseStatementsFunction · 0.85
make_unexpectedFunction · 0.85
moveFunction · 0.85
RuntimeErrorClass · 0.85
StrCatFunction · 0.85
emptyMethod · 0.45
sizeMethod · 0.45
evaluateMethod · 0.45
whatMethod · 0.45

Tested by 1

TestNodeMethod · 0.68