代写代考 * Simple regular expression matching.

* Simple regular expression matching.
* The Practice of Programming
* . Kernighan,
* Modified by: . Brown

Copyright By PowCoder代写 加微信 powcoder

* Purpose: This library is a modified version of a KLEE tutorial adapted for academic use.

#include

static int matchhere(char*,char*);

static int matchstar(int c, char *re, char *text) {
if (matchhere(re, text))
} while (*text != ‘\0’ && (*text++ == c || c== ‘.’));

static int matchhere(char *re, char *text) {
if (re[1] == ‘*’)
return matchstar(re[0], re+2, text);
if (re[0] == ‘$’ && re[1]==’\0′)
return *text == ‘\0′;
if (*text!=’\0′ && (re[0]==’.’ || re[0]==*text))
return matchhere(re+1, text+1);

int match(char *re, char *text) {
if (re[0] == ‘^’)
return matchhere(re+1, text);
if (matchhere(re, text))
} while (*text++ != ‘\0’);

* Harness for testing with KLEE.

// The size of the buffer to test with.
#define SIZE 7

int main() {
// The input regular expression.
char re[SIZE];

// Make the input symbolic.
klee_make_symbolic(re, sizeof re, “re”);

// Tell KLEE to assume the symbolic input is a null-terminated string
klee_assume(re[SIZE – 1] == ‘\0’);

// Try to match against a constant string “hello”.
match(re, “cs6340”);

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com