Skip to content

tgs/fishrob

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Fishrob - a partial implementation of Rob Pike's Structural Regexps

I was super impressed by this paper, and I just had to try messing with it a bit. I found it because of this blog post at Hacker School.

Hopefully, this will be interesting to someone - it's nothing more than a start.

Here's a demo - the debian_package_file string is defined in demo.py.

# Extract groups of non-blank lines,
# Where the Section is 'non-free/web',
# Split into individual lines,
# Take the one that's the package name,
# And print it.
fishrob(debian_package_file) \
    .x(r'(.+\n)+') \
    .g(r'Section: non-free/web') \
    .x(r'.+\n') \
    .g(r'^Package:') \
    .p()
# Should print:
#   Package: album-data
#   Package: album

Compare it to Pike's example on page 5 (adapted to Debian Package files):

x/(.+\n)+/ g/Section: non-free\/web/ x/.*\n/ g/Package/p

Keep being awesome, Hacker School!

About

A partial implementation of Rob Pike's Structural Regexps

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages