7267
|
1 # lex_many_tokens.py
|
|
2 #
|
|
3 # Test lex's ability to handle a large number of tokens (beyond the
|
|
4 # 100-group limit of the re module)
|
|
5
|
|
6 import sys
|
|
7 if ".." not in sys.path: sys.path.insert(0,"..")
|
|
8
|
|
9 import ply.lex as lex
|
|
10
|
|
11 tokens = ["TOK%d" % i for i in range(1000)]
|
|
12
|
|
13 for tok in tokens:
|
|
14 if sys.version_info[0] < 3:
|
|
15 exec("t_%s = '%s:'" % (tok,tok))
|
|
16 else:
|
|
17 exec("t_%s = '%s:'" % (tok,tok), globals())
|
|
18
|
|
19 t_ignore = " \t"
|
|
20
|
|
21 def t_error(t):
|
|
22 pass
|
|
23
|
|
24 lex.lex(optimize=1,lextab="manytab")
|
|
25 lex.runmain(data="TOK34: TOK143: TOK269: TOK372: TOK452: TOK561: TOK999:")
|
|
26
|
|
27
|