Show More
@@ -2217,18 +2217,12 b' def optimize(x, small):' | |||||
2217 | _aliassyminitletters = set(c for c in [chr(i) for i in xrange(256)] |
|
2217 | _aliassyminitletters = set(c for c in [chr(i) for i in xrange(256)] | |
2218 | if c.isalnum() or c in '._@$' or ord(c) > 127) |
|
2218 | if c.isalnum() or c in '._@$' or ord(c) > 127) | |
2219 |
|
2219 | |||
2220 | def _tokenizealias(program, lookup=None): |
|
2220 | def _parsealias(spec): | |
2221 |
"""Parse alias declaration/definition |
|
2221 | """Parse alias declaration/definition ``spec`` | |
2222 |
|
2222 | |||
2223 | This allows symbol names to use also ``$`` as an initial letter |
|
2223 | This allows symbol names to use also ``$`` as an initial letter | |
2224 | (for backward compatibility), and callers of this function should |
|
2224 | (for backward compatibility), and callers of this function should | |
2225 | examine whether ``$`` is used also for unexpected symbols or not. |
|
2225 | examine whether ``$`` is used also for unexpected symbols or not. | |
2226 | """ |
|
|||
2227 | return tokenize(program, lookup=lookup, |
|
|||
2228 | syminitletters=_aliassyminitletters) |
|
|||
2229 |
|
||||
2230 | def _parsealias(spec): |
|
|||
2231 | """Parse alias declaration/definition ``spec`` |
|
|||
2232 |
|
2226 | |||
2233 | >>> _parsealias('foo($1)') |
|
2227 | >>> _parsealias('foo($1)') | |
2234 | ('func', ('symbol', 'foo'), ('symbol', '$1')) |
|
2228 | ('func', ('symbol', 'foo'), ('symbol', '$1')) | |
@@ -2238,7 +2232,7 b' def _parsealias(spec):' | |||||
2238 | ParseError: ('invalid token', 4) |
|
2232 | ParseError: ('invalid token', 4) | |
2239 | """ |
|
2233 | """ | |
2240 | p = parser.parser(elements) |
|
2234 | p = parser.parser(elements) | |
2241 |
tree, pos = p.parse( |
|
2235 | tree, pos = p.parse(tokenize(spec, syminitletters=_aliassyminitletters)) | |
2242 | if pos != len(spec): |
|
2236 | if pos != len(spec): | |
2243 | raise error.ParseError(_('invalid token'), pos) |
|
2237 | raise error.ParseError(_('invalid token'), pos) | |
2244 | return parser.simplifyinfixops(tree, ('list', 'or')) |
|
2238 | return parser.simplifyinfixops(tree, ('list', 'or')) |
General Comments 0
You need to be logged in to leave comments.
Login now