initial (hacky af)

This commit is contained in:
2017-02-24 18:38:35 +01:00
commit ffeacdcb6c
8 changed files with 267 additions and 0 deletions

18
examples/bf.py Normal file
View File

@@ -0,0 +1,18 @@
import gll
def loop(string):
parser = gll.seq(gll.skip(gll.string("[")),
gll.many(op),
gll.skip(gll.string("]")),
tag="loop")
return parser(string)
op = (gll.string("+", tag="add") |
gll.string("-", tag="sub") |
gll.string(".", tag="out") |
gll.string(",", tag="in") |
gll.string(">", tag="fwd") |
gll.string("<", tag="bck") |
loop)
parser = gll.all(gll.many(op), tag="program")