Hi all!
I am beginning to use LEPL. It seems very promising but I have two problems.
I guess the answer is easy or already written somewhere, but I searched for
some time now and I did not found yet :(
Firstly, this very simple code:
with TraceVariables():
from lepl import *
PERCENT = Token('%')
TEXT = Token('[^\n]*')
comment = PERCENT & TEXT
print(comment.parse('% ThisIsAComment'))
outputs:
Traceback (most recent call last):
File
"/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packa ges/LEPL-5.0.0-py3.2.egg/lepl/stream/maxdepth.py",
line 55, in _matcher
(result2, stream2) = yield generator
StopIteration
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 6, in <module>
File
"/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packa ges/LEPL-5.0.0-py3.2.egg/lepl/core/config.py",
line 858, in parse
return self.get_parse()(input_, **kargs)
File
"/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packa ges/LEPL-5.0.0-py3.2.egg/lepl/core/parser.py",
line 257, in single
return next(raw(arg, **kargs))[0]
File
"/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packa ges/LEPL-5.0.0-py3.2.egg/lepl/core/parser.py",
line 161, in trampoline
value = stack[-1].generator.throw(value)
File
"/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packa ges/LEPL-5.0.0-py3.2.egg/lepl/stream/maxdepth.py",
line 61, in _matcher
raise FullFirstMatchException(stream1)
lepl.stream.maxdepth.FullFirstMatchException: The match failed in <string>
at '% ThisIsAComment' (line 1, character 1).
I do not really see why it does not work... I did some tests with only '%'and it is correctly detected.
The second (and last) point ; this simple code:
test = Token(String())
test.parse('"irt"')
produces:
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
File
"/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packa ges/LEPL-5.0.0-py3.2.egg/lepl/core/config.py",
line 858, in parse
return self.get_parse()(input_, **kargs)
File
"/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packa ges/LEPL-5.0.0-py3.2.egg/lepl/core/config.py",
line 815, in get_parse
return make_single(self.get_match())
File
"/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packa ges/LEPL-5.0.0-py3.2.egg/lepl/core/config.py",
line 723, in get_match
return self._raw_parser()
File
"/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packa ges/LEPL-5.0.0-py3.2.egg/lepl/core/config.py",
line 675, in _raw_parser
make_raw_parser(self, stream_factory, config)
File
"/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packa ges/LEPL-5.0.0-py3.2.egg/lepl/core/parser.py",
line 220, in make_raw_parser
matcher = rewriter(matcher)
File
"/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packa ges/LEPL-5.0.0-py3.2.egg/lepl/lexer/rewriters.py",
line 125, in __call__
return self.lexer(graph, tokens, self.alphabet, self.discard)
File
"/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packa ges/LEPL-5.0.0-py3.2.egg/lepl/lexer/lexer.py",
line 74, in __init__
token.compile(alphabet)
File
"/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packa ges/LEPL-5.0.0-py3.2.egg/lepl/lexer/matchers.py",
line 135, in compile
self.regexp = self.__to_regexp(self.regexp, self.alphabet)
File
"/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packa ges/LEPL-5.0.0-py3.2.egg/lepl/lexer/matchers.py",
line 155, in __to_regexp
'a regular expression: {0}', rewrite))
lepl.lexer.support.LexerError: A Token was specified with a matcher, but the
matcher could not be converted to a regular expression: And(NfaRegexp,
Transform, NfaRegexp)
It is as if the regexp behind String() was not recognized by LELP itself. Do
I miss something?
Thank you very much if you can help me or give me some clues :)