diff options
Diffstat (limited to 'test/lex_optimize4.py')
-rw-r--r-- | test/lex_optimize4.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/lex_optimize4.py b/test/lex_optimize4.py new file mode 100644 index 0000000..cc6e2a9 --- /dev/null +++ b/test/lex_optimize4.py @@ -0,0 +1,26 @@ +# ----------------------------------------------------------------------------- +# lex_optimize4.py +# ----------------------------------------------------------------------------- +import re +import sys + +if ".." not in sys.path: sys.path.insert(0,"..") +import ply.lex as lex + +tokens = [ + "PLUS", + "MINUS", + "NUMBER", + ] + +t_PLUS = r'\+?' +t_MINUS = r'-' +t_NUMBER = r'(\d+)' + +def t_error(t): + pass + + +# Build the lexer +lex.lex(optimize=True, lextab="opt4tab", reflags=re.UNICODE) +lex.runmain(data="3+4") |