Skip to content

Regular expressions matching to illustrate lexical analysis in MiniJava transpiler

Notifications You must be signed in to change notification settings

lascar-pacagi/regex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Regex

This repository contains the code to illustrate regular expressions and automata for the lexical analysis part of the MiniJava transpiler, which is documented on www.mrcoder.org.

To use the code in the ocaml interpreter do the following.

utop # #use "regex.ml";;

You can create a regular expression with the following code.

utop # let re = RE.regex_from_string "0*(100*)*1?";;

You can now create a non-deterministic finite automata equivalent to this regular expression with

utop # let nfa = NFA.init re;;

And now, you can test if a string is matched by the regular expression with

utop # NFA.full_match nfa "101010";;
- : bool = true

If you want to launch the test suite, you will need dune, you can install it with opam by executing the following command.

opam install dune

You can now launch the test suite with

dune exec ./test_re.exe

About

Regular expressions matching to illustrate lexical analysis in MiniJava transpiler

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages