Files
gll/examples/calc.py
2017-02-24 18:38:35 +01:00

10 lines
241 B
Python

import gll
ws = gll.skipmany(gll.whitespace(), tag="spaces")
num = gll.many1(gll.digit(), tag="number")
op = gll.string("+", tag="op") | gll.string("-", tag="op")
expr = gll.seq(num, ws, op, ws, num, tag="expr")
parser = gll.many(expr)