]>
git.saurik.com Git - cycript.git/blob - jammed.py
9 with open(sys
.argv
[1], 'r') as file:
11 line
= file.readline()
15 define
= re
.match('#define ([A-Za-z_]*) ([0-9]+)', line
)
17 defines
[define
.group(1)] = int(define
.group(2))
20 if not line
.startswith('static yyconst '):
24 begin
= line
.rindex(' ', 0, end
)
25 name
= line
[begin
+1:end
]
29 line
= file.readline()
31 if line
.find(';') != -1:
34 code
= code
.replace('{', '[')
35 code
= code
.replace('}', ']')
36 code
= code
.replace(';', ' ')
37 tables
[name
] = eval(code
)
39 yy_nxt
= tables
['yy_nxt']
40 yy_accept
= tables
['yy_accept']
41 yy_ec
= tables
['yy_ec']
43 YY_NUM_RULES
= defines
['YY_NUM_RULES']
45 jammed
= yy_accept
.index(YY_NUM_RULES
)
50 for ordinal
, equiv
in enumerate(yy_ec
):
51 equivs
[equiv
] = equivs
.get(equiv
, '') + chr(ordinal
)
53 starts
= set(range(1, len(yy_nxt
)))
54 for source
, table
in enumerate(yy_nxt
):
57 for equiv
, target
in enumerate(table
):
67 suffix
= after
.get(start
)
70 finish
[start
] = [[equivs
[c
] for c
in s
] for s
in suffix
]
78 for source
, table
in enumerate(yy_nxt
):
82 for equiv
, target
in enumerate(table
):
83 suffix
= before
.get(target
)
86 string
.extend([[equiv
] + s
for s
in suffix
])
89 after
[source
] = string