Adding support for compiling approximate matching patterns

Adds new "edit_distance" extparam
This commit is contained in:
Anatoly Burakov
2017-02-10 15:37:35 +00:00
committed by Matthew Barr
parent 60fc975c81
commit 2de6706df2
16 changed files with 804 additions and 28 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Intel Corporation
* Copyright (c) 2015-2017, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -48,7 +48,8 @@ enum ParamKey {
PARAM_NONE,
PARAM_MIN_OFFSET,
PARAM_MAX_OFFSET,
PARAM_MIN_LENGTH
PARAM_MIN_LENGTH,
PARAM_EDIT_DISTANCE
};
%%{
@@ -92,6 +93,10 @@ enum ParamKey {
ext->flags |= HS_EXT_FLAG_MIN_LENGTH;
ext->min_length = num;
break;
case PARAM_EDIT_DISTANCE:
ext->flags |= HS_EXT_FLAG_EDIT_DISTANCE;
ext->edit_distance = num;
break;
case PARAM_NONE:
default:
// No key specified, syntax invalid.
@@ -151,8 +156,9 @@ bool readExpression(const std::string &input, std::string &expr,
%%{
single_flag = [ismW8HPLVO];
param = ('min_offset' @{ key = PARAM_MIN_OFFSET; } |
'max_offset' @{ key = PARAM_MAX_OFFSET; } |
'min_length' @{ key = PARAM_MIN_LENGTH; } );
'max_offset' @{ key = PARAM_MAX_OFFSET; } |
'min_length' @{ key = PARAM_MIN_LENGTH; } |
'edit_distance' @{ key = PARAM_EDIT_DISTANCE; });
value = (digit @accumulateNum)+ >{num = 0;};
param_spec = (' '* param '=' value ' '*) >{ key = PARAM_NONE; }