From 32309e019f2ff7d9f69f3e0016f67439e81b8b30 Mon Sep 17 00:00:00 2001 From: Louis Burda Date: Sat, 30 Mar 2024 15:37:05 +0100 Subject: Rename to solve --- solve/ply-2.2/test/lex_state_norule.py | 42 ++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 solve/ply-2.2/test/lex_state_norule.py (limited to 'solve/ply-2.2/test/lex_state_norule.py') diff --git a/solve/ply-2.2/test/lex_state_norule.py b/solve/ply-2.2/test/lex_state_norule.py new file mode 100644 index 0000000..e48a319 --- /dev/null +++ b/solve/ply-2.2/test/lex_state_norule.py @@ -0,0 +1,42 @@ +# lex_state2.py +# +# Declaration of a state for which no rules are defined + +import sys +sys.path.insert(0,"..") + +import ply.lex as lex + +tokens = [ + "PLUS", + "MINUS", + "NUMBER", + ] + +comment = 1 +states = (('comment', 'exclusive'), + ('example', 'exclusive')) + +t_PLUS = r'\+' +t_MINUS = r'-' +t_NUMBER = r'\d+' + +# Comments +def t_comment(t): + r'/\*' + t.lexer.begin('comment') + print "Entering comment state" + +def t_comment_body_part(t): + r'(.|\n)*\*/' + print "comment body", t + t.lexer.begin('INITIAL') + +def t_error(t): + pass + +import sys + +lex.lex() + + -- cgit v1.2.3-71-gd317