initial (hacky af)
This commit is contained in:
18
examples/bf.py
Normal file
18
examples/bf.py
Normal 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")
|
Reference in New Issue
Block a user