mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2026-01-02 06:34:41 +03:00
ng: split NGWrapper into NGHolder, ExpressionInfo
We now use NGHolder for all graph information, while other expression properties (report, flag information, etc) go in new class ExpressionInfo.
This commit is contained in:
committed by
Matthew Barr
parent
fadfab6d8c
commit
5dfae12a62
@@ -35,8 +35,8 @@
|
||||
|
||||
#include "ue2common.h"
|
||||
#include "database.h"
|
||||
#include "compiler/expression_info.h"
|
||||
#include "parser/Component.h"
|
||||
#include "som/som.h"
|
||||
|
||||
#include <memory>
|
||||
#include <boost/core/noncopyable.hpp>
|
||||
@@ -50,35 +50,32 @@ struct CompileContext;
|
||||
struct Grey;
|
||||
struct target_t;
|
||||
class NG;
|
||||
class NGHolder;
|
||||
class ReportManager;
|
||||
class NGWrapper;
|
||||
|
||||
/** Class gathering together the pieces of a parsed expression.
|
||||
* Note: Owns the provided component.
|
||||
*/
|
||||
/** \brief Class gathering together the pieces of a parsed expression. */
|
||||
class ParsedExpression : boost::noncopyable {
|
||||
public:
|
||||
ParsedExpression(unsigned index, const char *expression, unsigned flags,
|
||||
ReportID actionId, const hs_expr_ext *ext = nullptr);
|
||||
ReportID report, const hs_expr_ext *ext = nullptr);
|
||||
|
||||
bool utf8; //!< UTF-8 mode flag specified
|
||||
/** \brief Expression information (from flags, extparam etc) */
|
||||
ExpressionInfo expr;
|
||||
|
||||
/** \brief root node of parsed component tree. */
|
||||
std::unique_ptr<ue2::Component> component;
|
||||
/** \brief Root node of parsed component tree. */
|
||||
std::unique_ptr<Component> component;
|
||||
};
|
||||
|
||||
const bool allow_vacuous; //!< HS_FLAG_ALLOWEMPTY specified
|
||||
const bool highlander; //!< HS_FLAG_SINGLEMATCH specified
|
||||
const bool prefilter; //!< HS_FLAG_PREFILTER specified
|
||||
som_type som; //!< chosen SOM mode, or SOM_NONE
|
||||
/**
|
||||
* \brief Class gathering together the pieces of an expression that has been
|
||||
* built into an NFA graph.
|
||||
*/
|
||||
struct BuiltExpression {
|
||||
/** \brief Expression information (from flags, extparam etc) */
|
||||
ExpressionInfo expr;
|
||||
|
||||
/** \brief index in expressions array passed to \ref hs_compile_multi */
|
||||
const unsigned index;
|
||||
|
||||
const ReportID id; //!< user-specified pattern ID
|
||||
u64a min_offset; //!< 0 if not used
|
||||
u64a max_offset; //!< MAX_OFFSET if not used
|
||||
u64a min_length; //!< 0 if not used
|
||||
u32 edit_distance; //!< 0 if not used
|
||||
/** \brief Built Glushkov NFA graph. */
|
||||
std::unique_ptr<NGHolder> g;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -95,12 +92,12 @@ public:
|
||||
* @param ext
|
||||
* Struct containing extra parameters for this expression, or NULL if
|
||||
* none.
|
||||
* @param actionId
|
||||
* @param report
|
||||
* The identifier to associate with the expression; returned by engine on
|
||||
* match.
|
||||
*/
|
||||
void addExpression(NG &ng, unsigned index, const char *expression,
|
||||
unsigned flags, const hs_expr_ext *ext, ReportID actionId);
|
||||
unsigned flags, const hs_expr_ext *ext, ReportID report);
|
||||
|
||||
/**
|
||||
* Build a Hyperscan database out of the expressions we've been given. A
|
||||
@@ -128,9 +125,8 @@ struct hs_database *build(NG &ng, unsigned int *length);
|
||||
* @return
|
||||
* nullptr on error.
|
||||
*/
|
||||
std::unique_ptr<NGWrapper> buildWrapper(ReportManager &rm,
|
||||
const CompileContext &cc,
|
||||
const ParsedExpression &expr);
|
||||
BuiltExpression buildGraph(ReportManager &rm, const CompileContext &cc,
|
||||
const ParsedExpression &expr);
|
||||
|
||||
/**
|
||||
* Build a platform_t out of a target_t.
|
||||
|
||||
Reference in New Issue
Block a user