Skip to content

eugene-eeo/katana

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Katana

A razor sharp, experimental parser-combinator library for Python. It's goals include being composable, easy to understand, and elegant while being reasonably performant. Katana is being built with a functional style- immutable data structures, no mutation and requires the pyrsistent library.

Katana requires a strict separation of the tokenisation and parsing phase; tokenisation is done via regexes and parsing is simply the grouping of those tokens:

from katana.scanner import rexpr, scan

dollar = rexpr(r'\$')
number = rexpr(r'[0-9]+')
tokens = scan([dollar, number], '$123')

Then the parsing phase:

from katana.term import term
from katana.compound import sequence
from katana.utils import parse

dollar_term = term(dollar)
number_term = term(number)
usd = sequence(dollar_term, number_term)

parse(usd, tokens)

About

razor sharp parser engine for python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages