568 lines
19 KiB
Diff
568 lines
19 KiB
Diff
diff --git a/configure.ac b/configure.ac
|
|
index a135e01..f565b87 100644
|
|
--- a/configure.ac
|
|
+++ b/configure.ac
|
|
@@ -290,54 +290,28 @@ AC_SUBST([catch_LIBS])
|
|
#
|
|
AC_ARG_WITH([bundled-pegtl], AS_HELP_STRING([--with-bundled-pegtl], [Build using the bundled PEGTL library]), [with_bundled_pegtl=$withval], [with_bundled_pegtl=no])
|
|
if test "x$with_bundled_pegtl" = xyes; then
|
|
- pegtl_CFLAGS="-I\$(top_srcdir)/src/ThirdParty/PEGTL"
|
|
- pegtl_AC_CFLAGS="-I$srcdir/src/ThirdParty/PEGTL"
|
|
+ pegtl_CFLAGS="-I\$(top_srcdir)/src/ThirdParty/PEGTL/include"
|
|
+ pegtl_AC_CFLAGS="-I$srcdir/src/ThirdParty/PEGTL/include"
|
|
pegtl_LIBS=""
|
|
AC_MSG_NOTICE([Using bundled PEGTL library])
|
|
pegtl_summary="bundled; $pegtl_CFLAGS $pegtl_LIBS"
|
|
else
|
|
- SAVE_CPPFLAGS=$CPPFLAGS
|
|
- CPPFLAGS="-std=c++11 $CPPFLAGS"
|
|
- AC_LANG_PUSH([C++])
|
|
- AC_CHECK_HEADER([pegtl.hh], [], [AC_MSG_FAILURE(pegtl.hh not found or not usable. Re-run with --with-bundled-pegtl to use the bundled library.)])
|
|
- AC_LANG_POP
|
|
pegtl_CFLAGS=""
|
|
pegtl_AC_CFLAGS=""
|
|
pegtl_LIBS=""
|
|
- CPPFLAGS=$SAVE_CPPFLAGS
|
|
pegtl_summary="system-wide; $pegtl_CFLAGS $pegtl_LIBS"
|
|
fi
|
|
AC_SUBST([pegtl_CFLAGS])
|
|
AC_SUBST([pegtl_AC_CFLAGS])
|
|
AC_SUBST([pegtl_LIBS])
|
|
|
|
-#
|
|
-# Check whether the available PEGTL library is compatible
|
|
-# with version 1.3.1 or older.
|
|
-#
|
|
SAVE_CPPFLAGS=$CPPFLAGS
|
|
-CPPFLAGS="-std=c++11 $pegtl_AC_CFLAGS"
|
|
+CPPFLAGS="-std=c++11 $CPPFLAGS $pegtl_AC_CFLAGS"
|
|
AC_LANG_PUSH([C++])
|
|
-AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
|
|
-#include <pegtl.hh>
|
|
-#include <string>
|
|
-int main(void)
|
|
-{
|
|
- struct grammar
|
|
- : pegtl::one<'g'> {};
|
|
- try {
|
|
- pegtl::parse_string<grammar>(std::string(), std::string());
|
|
- } catch(const pegtl::parse_error& ex) {
|
|
- auto b = ex.positions[0].byte_in_line;
|
|
- }
|
|
- return 0;
|
|
-}
|
|
-]])],
|
|
-[have_pegtl_lte_131=no], [have_pegtl_lte_131=yes])
|
|
+AC_CHECK_HEADER([tao/pegtl.hpp],
|
|
+ [AC_DEFINE([HAVE_TAO_PEGTL_HPP], [1], [PEGTL header file with .hpp extension is present])],
|
|
+ [AC_MSG_FAILURE(PEGTL header file not found or not usable. Re-run with --with-bundled-pegtl to use the bundled library.)])
|
|
AC_LANG_POP
|
|
-if test "x$have_pegtl_lte_131" = xyes; then
|
|
- AC_DEFINE([HAVE_PEGTL_LTE_1_3_1], [1], [PEGTL version less than or equal to 1.3.1])
|
|
-fi
|
|
CPPFLAGS=$SAVE_CPPFLAGS
|
|
|
|
#
|
|
diff --git a/src/Library/RuleParser/Actions.hpp b/src/Library/RuleParser/Actions.hpp
|
|
index 3e185f4..2b21bd2 100644
|
|
--- a/src/Library/RuleParser/Actions.hpp
|
|
+++ b/src/Library/RuleParser/Actions.hpp
|
|
@@ -24,7 +24,7 @@
|
|
#include "Utility.hpp"
|
|
#include "Common/Utility.hpp"
|
|
|
|
-#include <pegtl.hh>
|
|
+#include <tao/pegtl.hpp>
|
|
|
|
namespace usbguard
|
|
{
|
|
@@ -47,7 +47,7 @@ namespace usbguard
|
|
struct str_if;
|
|
|
|
template<typename Rule>
|
|
- struct rule_parser_actions : pegtl::nothing<Rule> {};
|
|
+ struct rule_parser_actions : tao::pegtl::nothing<Rule> {};
|
|
|
|
template<>
|
|
struct rule_parser_actions<target> {
|
|
@@ -58,7 +58,7 @@ namespace usbguard
|
|
rule.setTarget(Rule::targetFromString(in.string()));
|
|
}
|
|
catch (const std::exception& ex) {
|
|
- throw pegtl::parse_error(ex.what(), in);
|
|
+ throw tao::pegtl::parse_error(ex.what(), in);
|
|
}
|
|
}
|
|
};
|
|
@@ -75,7 +75,7 @@ namespace usbguard
|
|
rule.setDeviceID(device_id);
|
|
}
|
|
catch (const std::exception& ex) {
|
|
- throw pegtl::parse_error(ex.what(), in);
|
|
+ throw tao::pegtl::parse_error(ex.what(), in);
|
|
}
|
|
}
|
|
};
|
|
@@ -87,7 +87,7 @@ namespace usbguard
|
|
}
|
|
|
|
template<typename Rule>
|
|
- struct name_actions : pegtl::nothing<Rule> {};
|
|
+ struct name_actions : tao::pegtl::nothing<Rule> {};
|
|
|
|
template<>
|
|
struct name_actions<str_name> {
|
|
@@ -95,7 +95,7 @@ namespace usbguard
|
|
static void apply(const Input& in, Rule& rule)
|
|
{
|
|
if (!rule.attributeName().empty()) {
|
|
- throw pegtl::parse_error("name attribute already defined", in);
|
|
+ throw tao::pegtl::parse_error("name attribute already defined", in);
|
|
}
|
|
}
|
|
};
|
|
@@ -109,7 +109,7 @@ namespace usbguard
|
|
rule.attributeName().append(stringValueFromRule(in.string()));
|
|
}
|
|
catch (const std::exception& ex) {
|
|
- throw pegtl::parse_error(ex.what(), in);
|
|
+ throw tao::pegtl::parse_error(ex.what(), in);
|
|
}
|
|
}
|
|
};
|
|
@@ -123,13 +123,13 @@ namespace usbguard
|
|
rule.attributeName().setSetOperator(Rule::setOperatorFromString(in.string()));
|
|
}
|
|
catch (const std::exception& ex) {
|
|
- throw pegtl::parse_error(ex.what(), in);
|
|
+ throw tao::pegtl::parse_error(ex.what(), in);
|
|
}
|
|
}
|
|
};
|
|
|
|
template<typename Rule>
|
|
- struct id_actions : pegtl::nothing<Rule> {};
|
|
+ struct id_actions : tao::pegtl::nothing<Rule> {};
|
|
|
|
template<>
|
|
struct id_actions<str_id> {
|
|
@@ -137,7 +137,7 @@ namespace usbguard
|
|
static void apply(const Input& in, Rule& rule)
|
|
{
|
|
if (!rule.attributeDeviceID().empty()) {
|
|
- throw pegtl::parse_error("id attribute already defined", in);
|
|
+ throw tao::pegtl::parse_error("id attribute already defined", in);
|
|
}
|
|
}
|
|
};
|
|
@@ -154,7 +154,7 @@ namespace usbguard
|
|
rule.attributeDeviceID().append(device_id);
|
|
}
|
|
catch (const std::exception& ex) {
|
|
- throw pegtl::parse_error(ex.what(), in);
|
|
+ throw tao::pegtl::parse_error(ex.what(), in);
|
|
}
|
|
}
|
|
};
|
|
@@ -168,13 +168,13 @@ namespace usbguard
|
|
rule.attributeDeviceID().setSetOperator(Rule::setOperatorFromString(in.string()));
|
|
}
|
|
catch (const std::exception& ex) {
|
|
- throw pegtl::parse_error(ex.what(), in);
|
|
+ throw tao::pegtl::parse_error(ex.what(), in);
|
|
}
|
|
}
|
|
};
|
|
|
|
template<typename Rule>
|
|
- struct hash_actions : pegtl::nothing<Rule> {};
|
|
+ struct hash_actions : tao::pegtl::nothing<Rule> {};
|
|
|
|
template<>
|
|
struct hash_actions<str_hash> {
|
|
@@ -182,7 +182,7 @@ namespace usbguard
|
|
static void apply(const Input& in, Rule& rule)
|
|
{
|
|
if (!rule.attributeHash().empty()) {
|
|
- throw pegtl::parse_error("hash attribute already defined", in);
|
|
+ throw tao::pegtl::parse_error("hash attribute already defined", in);
|
|
}
|
|
}
|
|
};
|
|
@@ -196,7 +196,7 @@ namespace usbguard
|
|
rule.attributeHash().append(stringValueFromRule(in.string()));
|
|
}
|
|
catch (const std::exception& ex) {
|
|
- throw pegtl::parse_error(ex.what(), in);
|
|
+ throw tao::pegtl::parse_error(ex.what(), in);
|
|
}
|
|
}
|
|
};
|
|
@@ -210,13 +210,13 @@ namespace usbguard
|
|
rule.attributeHash().setSetOperator(Rule::setOperatorFromString(in.string()));
|
|
}
|
|
catch (const std::exception& ex) {
|
|
- throw pegtl::parse_error(ex.what(), in);
|
|
+ throw tao::pegtl::parse_error(ex.what(), in);
|
|
}
|
|
}
|
|
};
|
|
|
|
template<typename Rule>
|
|
- struct parent_hash_actions : pegtl::nothing<Rule> {};
|
|
+ struct parent_hash_actions : tao::pegtl::nothing<Rule> {};
|
|
|
|
template<>
|
|
struct parent_hash_actions<str_parent_hash> {
|
|
@@ -224,7 +224,7 @@ namespace usbguard
|
|
static void apply(const Input& in, Rule& rule)
|
|
{
|
|
if (!rule.attributeParentHash().empty()) {
|
|
- throw pegtl::parse_error("parent-hash attribute already defined", in);
|
|
+ throw tao::pegtl::parse_error("parent-hash attribute already defined", in);
|
|
}
|
|
}
|
|
};
|
|
@@ -238,7 +238,7 @@ namespace usbguard
|
|
rule.attributeParentHash().append(stringValueFromRule(in.string()));
|
|
}
|
|
catch (const std::exception& ex) {
|
|
- throw pegtl::parse_error(ex.what(), in);
|
|
+ throw tao::pegtl::parse_error(ex.what(), in);
|
|
}
|
|
}
|
|
};
|
|
@@ -252,13 +252,13 @@ namespace usbguard
|
|
rule.attributeParentHash().setSetOperator(Rule::setOperatorFromString(in.string()));
|
|
}
|
|
catch (const std::exception& ex) {
|
|
- throw pegtl::parse_error(ex.what(), in);
|
|
+ throw tao::pegtl::parse_error(ex.what(), in);
|
|
}
|
|
}
|
|
};
|
|
|
|
template<typename Rule>
|
|
- struct serial_actions : pegtl::nothing<Rule> {};
|
|
+ struct serial_actions : tao::pegtl::nothing<Rule> {};
|
|
|
|
template<>
|
|
struct serial_actions<str_serial> {
|
|
@@ -266,7 +266,7 @@ namespace usbguard
|
|
static void apply(const Input& in, Rule& rule)
|
|
{
|
|
if (!rule.attributeSerial().empty()) {
|
|
- throw pegtl::parse_error("serial attribute already defined", in);
|
|
+ throw tao::pegtl::parse_error("serial attribute already defined", in);
|
|
}
|
|
}
|
|
};
|
|
@@ -280,7 +280,7 @@ namespace usbguard
|
|
rule.attributeSerial().append(stringValueFromRule(in.string()));
|
|
}
|
|
catch (const std::exception& ex) {
|
|
- throw pegtl::parse_error(ex.what(), in);
|
|
+ throw tao::pegtl::parse_error(ex.what(), in);
|
|
}
|
|
}
|
|
};
|
|
@@ -294,13 +294,13 @@ namespace usbguard
|
|
rule.attributeSerial().setSetOperator(Rule::setOperatorFromString(in.string()));
|
|
}
|
|
catch (const std::exception& ex) {
|
|
- throw pegtl::parse_error(ex.what(), in);
|
|
+ throw tao::pegtl::parse_error(ex.what(), in);
|
|
}
|
|
}
|
|
};
|
|
|
|
template<typename Rule>
|
|
- struct via_port_actions : pegtl::nothing<Rule> {};
|
|
+ struct via_port_actions : tao::pegtl::nothing<Rule> {};
|
|
|
|
template<>
|
|
struct via_port_actions<str_via_port> {
|
|
@@ -308,7 +308,7 @@ namespace usbguard
|
|
static void apply(const Input& in, Rule& rule)
|
|
{
|
|
if (!rule.attributeViaPort().empty()) {
|
|
- throw pegtl::parse_error("via-port attribute already defined", in);
|
|
+ throw tao::pegtl::parse_error("via-port attribute already defined", in);
|
|
}
|
|
}
|
|
};
|
|
@@ -322,7 +322,7 @@ namespace usbguard
|
|
rule.attributeViaPort().append(stringValueFromRule(in.string()));
|
|
}
|
|
catch (const std::exception& ex) {
|
|
- throw pegtl::parse_error(ex.what(), in);
|
|
+ throw tao::pegtl::parse_error(ex.what(), in);
|
|
}
|
|
}
|
|
};
|
|
@@ -336,13 +336,13 @@ namespace usbguard
|
|
rule.attributeViaPort().setSetOperator(Rule::setOperatorFromString(in.string()));
|
|
}
|
|
catch (const std::exception& ex) {
|
|
- throw pegtl::parse_error(ex.what(), in);
|
|
+ throw tao::pegtl::parse_error(ex.what(), in);
|
|
}
|
|
}
|
|
};
|
|
|
|
template<typename Rule>
|
|
- struct with_interface_actions : pegtl::nothing<Rule> {};
|
|
+ struct with_interface_actions : tao::pegtl::nothing<Rule> {};
|
|
|
|
template<>
|
|
struct with_interface_actions<str_with_interface> {
|
|
@@ -350,7 +350,7 @@ namespace usbguard
|
|
static void apply(const Input& in, Rule& rule)
|
|
{
|
|
if (!rule.attributeWithInterface().empty()) {
|
|
- throw pegtl::parse_error("with-interface attribute already defined", in);
|
|
+ throw tao::pegtl::parse_error("with-interface attribute already defined", in);
|
|
}
|
|
}
|
|
};
|
|
@@ -365,7 +365,7 @@ namespace usbguard
|
|
rule.attributeWithInterface().append(interface_type);
|
|
}
|
|
catch (const std::exception& ex) {
|
|
- throw pegtl::parse_error(ex.what(), in);
|
|
+ throw tao::pegtl::parse_error(ex.what(), in);
|
|
}
|
|
}
|
|
};
|
|
@@ -379,13 +379,13 @@ namespace usbguard
|
|
rule.attributeWithInterface().setSetOperator(Rule::setOperatorFromString(in.string()));
|
|
}
|
|
catch (const std::exception& ex) {
|
|
- throw pegtl::parse_error(ex.what(), in);
|
|
+ throw tao::pegtl::parse_error(ex.what(), in);
|
|
}
|
|
}
|
|
};
|
|
|
|
template<typename Rule>
|
|
- struct condition_actions : pegtl::nothing<Rule> {};
|
|
+ struct condition_actions : tao::pegtl::nothing<Rule> {};
|
|
|
|
template<>
|
|
struct condition_actions<str_if> {
|
|
@@ -393,7 +393,7 @@ namespace usbguard
|
|
static void apply(const Input& in, Rule& rule)
|
|
{
|
|
if (!rule.attributeConditions().empty()) {
|
|
- throw pegtl::parse_error("conditions already defined", in);
|
|
+ throw tao::pegtl::parse_error("conditions already defined", in);
|
|
}
|
|
}
|
|
};
|
|
@@ -407,7 +407,7 @@ namespace usbguard
|
|
rule.attributeConditions().append(RuleCondition(in.string()));
|
|
}
|
|
catch (const std::exception& ex) {
|
|
- throw pegtl::parse_error(ex.what(), in);
|
|
+ throw tao::pegtl::parse_error(ex.what(), in);
|
|
}
|
|
}
|
|
};
|
|
@@ -421,7 +421,7 @@ namespace usbguard
|
|
rule.attributeConditions().setSetOperator(Rule::setOperatorFromString(in.string()));
|
|
}
|
|
catch (const std::exception& ex) {
|
|
- throw pegtl::parse_error(ex.what(), in);
|
|
+ throw tao::pegtl::parse_error(ex.what(), in);
|
|
}
|
|
}
|
|
};
|
|
diff --git a/src/Library/RuleParser/Grammar.hpp b/src/Library/RuleParser/Grammar.hpp
|
|
index 9bd4a15..4d785c0 100644
|
|
--- a/src/Library/RuleParser/Grammar.hpp
|
|
+++ b/src/Library/RuleParser/Grammar.hpp
|
|
@@ -22,37 +22,37 @@
|
|
#endif
|
|
|
|
#include "Actions.hpp"
|
|
-#include <pegtl.hh>
|
|
|
|
-using namespace pegtl;
|
|
+#include <tao/pegtl.hpp>
|
|
|
|
namespace usbguard
|
|
{
|
|
namespace RuleParser
|
|
{
|
|
+ using namespace tao::pegtl;
|
|
/*
|
|
* Rule language keywords
|
|
*/
|
|
- struct str_allow : pegtl_string_t("allow") {};
|
|
- struct str_block : pegtl_string_t("block") {};
|
|
- struct str_reject : pegtl_string_t("reject") {};
|
|
- struct str_match : pegtl_string_t("match") {};
|
|
- struct str_device : pegtl_string_t("device") {};
|
|
-
|
|
- struct str_name : pegtl_string_t("name") {};
|
|
- struct str_hash : pegtl_string_t("hash") {};
|
|
- struct str_parent_hash : pegtl_string_t("parent-hash") {};
|
|
- struct str_via_port : pegtl_string_t("via-port") {};
|
|
- struct str_with_interface : pegtl_string_t("with-interface") {};
|
|
- struct str_serial : pegtl_string_t("serial") {};
|
|
- struct str_if : pegtl_string_t("if") {};
|
|
- struct str_id : pegtl_string_t("id") {};
|
|
-
|
|
- struct str_all_of : pegtl_string_t("all-of") {};
|
|
- struct str_one_of : pegtl_string_t("one-of") {};
|
|
- struct str_none_of : pegtl_string_t("none-of") {};
|
|
- struct str_equals : pegtl_string_t("equals") {};
|
|
- struct str_equals_ordered : pegtl_string_t("equals-ordered") {};
|
|
+ struct str_allow : TAOCPP_PEGTL_STRING("allow") {};
|
|
+ struct str_block : TAOCPP_PEGTL_STRING("block") {};
|
|
+ struct str_reject : TAOCPP_PEGTL_STRING("reject") {};
|
|
+ struct str_match : TAOCPP_PEGTL_STRING("match") {};
|
|
+ struct str_device : TAOCPP_PEGTL_STRING("device") {};
|
|
+
|
|
+ struct str_name : TAOCPP_PEGTL_STRING("name") {};
|
|
+ struct str_hash : TAOCPP_PEGTL_STRING("hash") {};
|
|
+ struct str_parent_hash : TAOCPP_PEGTL_STRING("parent-hash") {};
|
|
+ struct str_via_port : TAOCPP_PEGTL_STRING("via-port") {};
|
|
+ struct str_with_interface : TAOCPP_PEGTL_STRING("with-interface") {};
|
|
+ struct str_serial : TAOCPP_PEGTL_STRING("serial") {};
|
|
+ struct str_if : TAOCPP_PEGTL_STRING("if") {};
|
|
+ struct str_id : TAOCPP_PEGTL_STRING("id") {};
|
|
+
|
|
+ struct str_all_of : TAOCPP_PEGTL_STRING("all-of") {};
|
|
+ struct str_one_of : TAOCPP_PEGTL_STRING("one-of") {};
|
|
+ struct str_none_of : TAOCPP_PEGTL_STRING("none-of") {};
|
|
+ struct str_equals : TAOCPP_PEGTL_STRING("equals") {};
|
|
+ struct str_equals_ordered : TAOCPP_PEGTL_STRING("equals-ordered") {};
|
|
|
|
/*
|
|
* Generic rule attribute
|
|
diff --git a/src/Library/UEventParser.cpp b/src/Library/UEventParser.cpp
|
|
index 2e0ce39..aebe948 100644
|
|
--- a/src/Library/UEventParser.cpp
|
|
+++ b/src/Library/UEventParser.cpp
|
|
@@ -27,7 +27,9 @@
|
|
#include "usbguard/Logger.hpp"
|
|
|
|
#include <fstream>
|
|
-#include <pegtl/trace.hh>
|
|
+
|
|
+#include <tao/pegtl/contrib/tracer.hpp>
|
|
+using namespace tao;
|
|
|
|
namespace usbguard
|
|
{
|
|
@@ -114,25 +116,14 @@ namespace usbguard
|
|
void parseUEventFromString(const std::string& uevent_string, UEvent& uevent, bool trace)
|
|
{
|
|
try {
|
|
-#if HAVE_PEGTL_LTE_1_3_1
|
|
+ tao::pegtl::string_input<> in(uevent_string, std::string());
|
|
|
|
if (!trace) {
|
|
- pegtl::parse<G, UEventParser::actions>(uevent_string, std::string(), uevent);
|
|
+ tao::pegtl::parse<G, UEventParser::actions>(in, uevent);
|
|
}
|
|
else {
|
|
- pegtl::parse<G, UEventParser::actions, pegtl::tracer>(uevent_string, std::string(), uevent);
|
|
- }
|
|
-
|
|
-#else
|
|
-
|
|
- if (!trace) {
|
|
- pegtl::parse_string<G, UEventParser::actions>(uevent_string, std::string(), uevent);
|
|
+ tao::pegtl::parse<G, UEventParser::actions, tao::pegtl::tracer>(in, uevent);
|
|
}
|
|
- else {
|
|
- pegtl::parse_string<G, UEventParser::actions, pegtl::tracer>(uevent_string, std::string(), uevent);
|
|
- }
|
|
-
|
|
-#endif
|
|
}
|
|
catch (...) {
|
|
throw;
|
|
diff --git a/src/Library/UEventParser.hpp b/src/Library/UEventParser.hpp
|
|
index 856d5ff..4261bd5 100644
|
|
--- a/src/Library/UEventParser.hpp
|
|
+++ b/src/Library/UEventParser.hpp
|
|
@@ -23,9 +23,7 @@
|
|
|
|
#include "usbguard/Typedefs.hpp"
|
|
|
|
-#include <pegtl.hh>
|
|
-
|
|
-using namespace pegtl;
|
|
+#include <tao/pegtl.hpp>
|
|
|
|
namespace usbguard
|
|
{
|
|
@@ -33,6 +31,8 @@ namespace usbguard
|
|
|
|
namespace UEventParser
|
|
{
|
|
+ using namespace tao::pegtl;
|
|
+
|
|
struct value
|
|
: seq<not_one<'\0', '\n'>, star<not_one<'\0', '\n'>>> {};
|
|
|
|
diff --git a/src/Library/public/usbguard/RuleParser.cpp b/src/Library/public/usbguard/RuleParser.cpp
|
|
index 4061e01..140bf14 100644
|
|
--- a/src/Library/public/usbguard/RuleParser.cpp
|
|
+++ b/src/Library/public/usbguard/RuleParser.cpp
|
|
@@ -34,7 +34,7 @@
|
|
#include <stdexcept>
|
|
#include <stdlib.h>
|
|
|
|
-#include <pegtl/trace.hh>
|
|
+#include <tao/pegtl/contrib/tracer.hpp>
|
|
|
|
namespace usbguard
|
|
{
|
|
@@ -42,35 +42,21 @@ namespace usbguard
|
|
{
|
|
try {
|
|
Rule rule;
|
|
-#if HAVE_PEGTL_LTE_1_3_1
|
|
+ tao::pegtl::string_input<> input(rule_spec, file);
|
|
|
|
if (!trace) {
|
|
- pegtl::parse<RuleParser::rule_grammar, RuleParser::rule_parser_actions>(rule_spec, file, rule);
|
|
+ tao::pegtl::parse<RuleParser::rule_grammar, RuleParser::rule_parser_actions>(input, rule);
|
|
}
|
|
else {
|
|
- pegtl::parse<RuleParser::rule_grammar, RuleParser::rule_parser_actions, pegtl::tracer>(rule_spec, file, rule);
|
|
+ tao::pegtl::parse<RuleParser::rule_grammar, RuleParser::rule_parser_actions, tao::pegtl::tracer>(input, rule);
|
|
}
|
|
|
|
-#else
|
|
-
|
|
- if (!trace) {
|
|
- pegtl::parse_string<RuleParser::rule_grammar, RuleParser::rule_parser_actions>(rule_spec, file, rule);
|
|
- }
|
|
- else {
|
|
- pegtl::parse_string<RuleParser::rule_grammar, RuleParser::rule_parser_actions, pegtl::tracer>(rule_spec, file, rule);
|
|
- }
|
|
-
|
|
-#endif
|
|
return rule;
|
|
}
|
|
- catch (const pegtl::parse_error& ex) {
|
|
+ catch (const tao::pegtl::parse_error& ex) {
|
|
RuleParserError error(rule_spec);
|
|
error.setHint(ex.what());
|
|
-#if HAVE_PEGTL_LTE_1_3_1
|
|
- error.setOffset(ex.positions[0].column);
|
|
-#else
|
|
error.setOffset(ex.positions[0].byte_in_line);
|
|
-#endif
|
|
|
|
if (!file.empty() || line != 0) {
|
|
error.setFileInfo(file, line);
|
|
--
|
|
2.13.6
|
|
|