Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/script_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ using ErrorReport = lexy_ext::_report_error<char*>;

Expected<ScriptFunction> ParseScript(const std::string& script)
{
char error_msgs_buffer[2048];
std::string error_msgs_buffer; // dynamically growing error buffer

auto input = lexy::string_input<lexy::utf8_encoding>(script);
auto result =
lexy::parse<BT::Grammar::stmt>(input, ErrorReport().to(error_msgs_buffer));

auto reporter = ErrorReport().to(std::back_inserter(error_msgs_buffer));
auto result = lexy::parse<BT::Grammar::stmt>(input, reporter);
if(result.has_value() && result.error_count() == 0)
{
try
Expand Down Expand Up @@ -69,11 +70,12 @@ BT::Expected<Any> ParseScriptAndExecute(Ast::Environment& env, const std::string

Result ValidateScript(const std::string& script)
{
char error_msgs_buffer[2048];
std::string error_msgs_buffer; // dynamically growing error buffer

auto input = lexy::string_input<lexy::utf8_encoding>(script);
auto result =
lexy::parse<BT::Grammar::stmt>(input, ErrorReport().to(error_msgs_buffer));

auto reporter = ErrorReport().to(std::back_inserter(error_msgs_buffer));
auto result = lexy::parse<BT::Grammar::stmt>(input, reporter);
if(result.has_value() && result.error_count() == 0)
{
try
Expand Down
Loading