Skip to content

A Canonical LR(1) Parser and Regex implementation similar to yacc and python's re

License

Notifications You must be signed in to change notification settings

obround/clrp-regex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

clrp-regex

As with many repositories I have uploded recently, this one was also written couple years ago. It is a complete LR(1) Parser, and Regular Expression generator (inspiration was taken from this excellent article by Russ Cox). In fact the parser for the regex generator was the LR(1) parser!

test_regex.py contains an example of the regex generator at work:

import clrp

regex = clrp.RegularExpression(r"[0-9]+")
print(regex.check("868993458990966743234"))

and test_clrp.py contains an example of the LR(1) parser generator at work.

Similar to yacc, the parser generator generates a standalone parser file (using the CLR1Parser.codegen method) for your grammar (it comes hardcoded with the entire parsing table). You can then import it and use it as you would a normal parser.

About

A Canonical LR(1) Parser and Regex implementation similar to yacc and python's re

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages