mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-03-22 08:50:24 +00:00
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@13 e7d03fd6-7b0d-0410-9947-9c21f3af8025
15 lines
368 B
Python
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)
|
|
|