Hello,
I'm using lepl 4.0 on Python 3.1.2 on Linux. The following grammar
works as expected:
CLine = ContinuedBLineFactory(Token(r'\\'))
expr0 = Token("[A-Za-z_][A-Za-z0-9_]*")
expr1 = Delayed()
call = expr1 & expr0 > List # Deliberately not expr0 & expr1
expr1 += call | expr0
program = expr1 & Eos()
parsed = program.parse("a b c")
print(parsed[0])
This prints:
List
+- List
| +- 'a'
| `- 'b'
`- 'c'
But when I replace the program= line with:
program = (CLine(expr1) & Eos())
program.config.default_line_aware(block_policy=rightmost)
I get this error:
Traceback (most recent call last):
File "/home/danarmak/workspace/ScalySynth/src/synth/test.py", line
27, in <module>
parsed = program.parse("a b c")
File "/usr/lib/python3.1/site-packages/LEPL-4.0-py3.1.egg/lepl/core/
config.py", line 914, in parse
return self.get_parse()(stream, **kargs)
File "/usr/lib/python3.1/site-packages/LEPL-4.0-py3.1.egg/lepl/core/
parser.py", line 246, in single
return next(raw(arg, **kargs))[0]
File "/usr/lib/python3.1/site-packages/LEPL-4.0-py3.1.egg/lepl/core/
parser.py", line 136, in trampoline
value = next(value.generator)
File "/usr/lib/python3.1/site-packages/LEPL-4.0-py3.1.egg/lepl/
stream/filters.py", line 390, in _match
generator = self.matcher._match(transform.stream)
File "/usr/lib/python3.1/site-packages/LEPL-4.0-py3.1.egg/lepl/
matchers/memo.py", line 221, in _match
if key not in self.__caches:
File "/usr/lib/python3.1/site-packages/LEPL-4.0-py3.1.egg/lepl/
stream/stream.py", line 380, in __hash__
return hash(self.__line) ^ self.__offset
File "/usr/lib/python3.1/site-packages/LEPL-4.0-py3.1.egg/lepl/
stream/stream.py", line 561, in __hash__
return self.source.hash_line(self)
File "/usr/lib/python3.1/site-packages/LEPL-4.0-py3.1.egg/lepl/
stream/stream.py", line 710, in hash_line
self.__class__.__name__))
Exception: No hash for [(['Tk9'], 'a')], <bound method Line.location
of [(['Tk9'], 'a')]> (CachingTransformedSource)
The grammar is deliberately left-recursive: I want it to describe left-
associative function calls. If I make it right-recursive (call = expr0
& expr1), then it works with the offside rule, but that's not what I
want. Can I achieve what I want and what does this error mean? (What
does memoization and eliminating left-recursive loops have to do with
making a grammar whitespace-aware?)
Thanks!
Daniel Ermak
--
You received this message because you are subscribed to the Google Groups "lepl" group.
To post to this group, send email to
le...@googlegroups.com.
To unsubscribe from this group, send email to
lepl+uns...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/lepl?hl=en.