Skip to content

ofcdune/regEx-Parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

This is a potent and fast RegEx parser written in pure C requiring nothing but the standard library. The speeds are comparable to those of PCRE and the code is being frequently updated to add its functionality.

This program incooperates a range of computer science principles such as parsing, recursion and the Szudjik function.

As of now, the functions

  • pattern *matcher_get_pattern(char *string, char pattern_string_len)
  • matcher *matcher_match_all(pattern *restrict pattern, const char *restrict string, int str_len);
    • char *matcher_get_match(matcher *restrict match_object, char *restrict string)

are the center of the programs functionality. The first function turns a string into a regex pattern (DFA). The second function finds all matches of a given string and the third function returns the found portion of the string.

The program works by

  1. parsing the pattern into a RegEx tree via a pratt parser (recursive descent parser)
  2. creating a DFA using the regular expression derivation function
  3. matching the input text with the DFA, the results get stored in the matcher object(s)
  4. extracting the string portion that has been found

The matcher object is defined as follows:

typedef struct matcher {
    unsigned int from;
    unsigned int to;

    struct matcher *next;
} matcher;

About

A potent regex parser written in C

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published