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
# -----------------------------------------------------------------------------
17
if ".." not in sys.path: sys.path.insert(0,"..")
28
def t_H_EDIT_DESCRIPTOR(t):
29
r"\d+H.*" # This grabs all of the remaining text
30
i = t.value.index('H')
33
# Adjust the tokenizing position
34
t.lexer.lexpos -= len(t.value) - (i+1+n)
35
t.value = t.value[i+1:i+1+n]
39
print("Illegal character '%s'" % t.value[0])
44
lex.runmain(data="3Habc 10Habcdefghij 2Hxy")