diff options
Diffstat (limited to 'example/hedit')
-rw-r--r-- | example/hedit/hedit.py | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/example/hedit/hedit.py b/example/hedit/hedit.py index 2e80675..32da745 100644 --- a/example/hedit/hedit.py +++ b/example/hedit/hedit.py @@ -15,34 +15,34 @@ # ----------------------------------------------------------------------------- import sys -sys.path.insert(0,"../..") +sys.path.insert(0, "../..") tokens = ( 'H_EDIT_DESCRIPTOR', - ) +) # Tokens t_ignore = " \t\n" + def t_H_EDIT_DESCRIPTOR(t): r"\d+H.*" # This grabs all of the remaining text i = t.value.index('H') n = eval(t.value[:i]) - + # Adjust the tokenizing position - t.lexer.lexpos -= len(t.value) - (i+1+n) - - t.value = t.value[i+1:i+1+n] - return t - + t.lexer.lexpos -= len(t.value) - (i + 1 + n) + + t.value = t.value[i + 1:i + 1 + n] + return t + + def t_error(t): print("Illegal character '%s'" % t.value[0]) t.lexer.skip(1) - + # Build the lexer import ply.lex as lex lex.lex() lex.runmain() - - |