mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-03-27 11:10:28 +00:00
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@12 e7d03fd6-7b0d-0410-9947-9c21f3af8025
14 lines
369 B
Python
14 lines
369 B
Python
import re, PyLR
|
|
|
|
def _intfunc(m):
|
|
return int(m.group(0))
|
|
|
|
class MathLex(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)
|