1 # -----------------------------------------------------------------------------
4 # Paring of Fortran H Edit descriptions (Contributed by Pearu Peterson)
6 # These tokens can't be easily tokenized because they are of the following
11 # where n is a positive integer and c1 ... cn are characters.
13 # This example shows how to modify the state of the lexer to parse
15 # -----------------------------------------------------------------------------
24 def t_H_EDIT_DESCRIPTOR(t
):
25 r
"\d+H.*" # This grabs all of the remaining text
26 i
= t
.value
.index('H')
29 # Adjust the tokenizing position
30 t
.lexer
.lexpos
-= len(t
.value
) - (i
+1+n
)
32 t
.value
= t
.value
[i
+1:i
+1+n
]
36 print "Illegal character '%s'" % t
.value
[0]