Skip to content
This repository has been archived by the owner on Mar 16, 2018. It is now read-only.

emlai/emregex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

emregex

Build Status Coverage Status

This is a simple public domain regex engine library and command-line tool, implemented in the C programming language without any external dependencies aside from the C standard library. It is far from full-featured, and there are currently still some known bugs (listed here). For information about the internals of this project, check the contents of the doc directory. Online documentation for the libemregex API can be found here.

Building from source

  1. The following dependencies are needed: a C compiler and CMake. To run the tests you also need Ruby.
  2. Run cmake -G "Unix Makefiles" . to generate a build system. If you wish to compile a release build with optimizations, add the flag -DCMAKE_BUILD_TYPE=Release to the command.
  3. Run make to build everything. This will generate an emregex executable in the project root directory.
  4. Run ctest --output-on-failure to run the tests, reporting any errors in case of test failure. make test can also be used to run the tests, but it doesn't print any error messages for failing test cases.

Usage

The emregex executable works pretty much like grep, except that it matches the whole input string, and currently only reads from standard input. This means that the most useful way to use it is to pipe something to it, e.g. like this:

echo "text to match" | ./emregex "regex pattern"

The program prints match and exits with the status 0 if the given string matches the regex passed as the argument, or no match with a non-zero exit status if it doesn't.

You can also print the abstract syntax tree of the parsed regex pattern by invoking emregex with the --print-ast flag. This might be useful for e.g. debugging the program.