linkchecker/PyLR/tests/MathLexer.py
2000-02-27 20:45:44 +00:00

15 lines
368 B
Python

import PyLR
def _intfunc(m):
return int(m.group(0))
class MathLexer(PyLR.Lexer):
def __init__(self):
PyLR.Lexer.__init__(self)
self.addpat(r"([1-9]([0-9]+)?)|0", "INT", _intfunc)
self.addpat(r"\+", "PLUS")
self.addpat(r"\*","TIMES")
self.addpat(r"\(", "LPAR")
self.addpat(r"\)", "RPAR")
self.addpat(r"\s+", "WS", None, 1)