Empirical
Classes | Namespaces | Functions
RegEx.h File Reference

Basic regular expression handler. More...

#include <ostream>
#include <sstream>
#include <string>
#include "../base/vector.h"
#include "../base/Ptr.h"
#include "BitSet.h"
#include "lexer_utils.h"
#include "NFA.h"
#include "string_utils.h"

Go to the source code of this file.

Classes

class  emp::RegEx
 A basic regular expression handler. More...
 

Namespaces

 emp
 If we are in emscripten, make sure to include the header.
 

Functions

static NFA emp::to_NFA (const RegEx &regex, size_t stop_id=1)
 Simple conversion of RegEx to NFA (mostly implemented in RegEx) More...
 
static DFA emp::to_DFA (const RegEx &regex)
 Conversion of RegEx to DFA, via NFA intermediate. More...
 

Detailed Description

Basic regular expression handler.

Note
This file is part of Empirical, https://github.com/devosoft/Empirical
Date
2016-2017
Note
Status: BETA

A fully (well, mostly) functional regular expression processor.

Special chars: '|' - or '*' - zero or more of previous '+' - one or more of previous '?' - previous is optional '.' - Match any character except
Pluse the following group contents (and change may translation rules) '(' and ')' - group contents '"' - Ignore special characters in contents (quotes still need to be escaped) '[' and ']' - character set – choose ONE character ^ as first char negates contents ; - indicates range UNLESS first or last.

Additional overloads for functions in lexer_utils.h:

static NFA to_NFA(const RegEx & regex, int stop_id=1); static DFA to_DFA(const RegEx & regex);

Todo:

Need to implement ^ and $ (beginning and end of line)

Need to implement {n}, {n,} and {n,m} (exactly n, at least n, and n-m copies, respecitvely)