annotate ply-3.8/test/lex_many_tokens.py @ 10776:b474172c9892
<b_jonas> slashlearn ance//Spelling of -ance/-ence words: advance, science, conference, experience, finance, insurance, licence, performance, reference, assistance, balance, defence, difference, distance, evidence, acceptance, appliance, audience, compliance, importance, influence, instance, intelligence, maintenance, preference, presence, sentence, sequence, substance, violence, absence, accordance, alliance, appearance, assurance, attendance, circumstance, clea
author |
HackBot |
date |
Fri, 21 Apr 2017 18:06:38 +0000 |
parents |
343ff337a19b |
children |
|
rev |
line source |
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
|