diff options
| author | Louis Burda <quent.burda@gmail.com> | 2024-03-30 15:37:05 +0100 |
|---|---|---|
| committer | Louis Burda <quent.burda@gmail.com> | 2024-03-30 15:37:05 +0100 |
| commit | 32309e019f2ff7d9f69f3e0016f67439e81b8b30 (patch) | |
| tree | ace9fccd48489648b0586a8f84da21839632d0b9 /chall/ply-2.2/test/calclex.py | |
| parent | 4007ea18f294aefb6128cbe82c5446cd8cb72c50 (diff) | |
| download | cscg24-lolpython-32309e019f2ff7d9f69f3e0016f67439e81b8b30.tar.gz cscg24-lolpython-32309e019f2ff7d9f69f3e0016f67439e81b8b30.zip | |
Rename to solve
Diffstat (limited to 'chall/ply-2.2/test/calclex.py')
| -rw-r--r-- | chall/ply-2.2/test/calclex.py | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/chall/ply-2.2/test/calclex.py b/chall/ply-2.2/test/calclex.py deleted file mode 100644 index 2550734..0000000 --- a/chall/ply-2.2/test/calclex.py +++ /dev/null @@ -1,49 +0,0 @@ -# ----------------------------------------------------------------------------- -# calclex.py -# ----------------------------------------------------------------------------- -import sys - -sys.path.append("..") -import ply.lex as lex - -tokens = ( - 'NAME','NUMBER', - 'PLUS','MINUS','TIMES','DIVIDE','EQUALS', - 'LPAREN','RPAREN', - ) - -# Tokens - -t_PLUS = r'\+' -t_MINUS = r'-' -t_TIMES = r'\*' -t_DIVIDE = r'/' -t_EQUALS = r'=' -t_LPAREN = r'\(' -t_RPAREN = r'\)' -t_NAME = r'[a-zA-Z_][a-zA-Z0-9_]*' - -def t_NUMBER(t): - r'\d+' - try: - t.value = int(t.value) - except ValueError: - print "Integer value too large", t.value - t.value = 0 - return t - -t_ignore = " \t" - -def t_newline(t): - r'\n+' - t.lineno += t.value.count("\n") - -def t_error(t): - print "Illegal character '%s'" % t.value[0] - t.lexer.skip(1) - -# Build the lexer -lex.lex() - - - |
