gpulost / lepl

Automatically exported from code.google.com/p/lepl
Other
0 stars 0 forks source link

cannot parse from a file #23

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
my understanding is that the following code should parse text from a file

-----------
from lepl import *

v = Token('[a-z]+') & Token(' +')
f = open('text.txt')
v.parse_file(f)
-----------

but it fails with the following error

----------
Traceback (most recent call last):
  File "t_string.py", line 6, in <module>
    v.parse_file(f)
  File "/HOME/.local/lib/python3.2/site-packages/LEPL-5.0.0-py3.2.egg/lepl/core/config.py", line 825, in parse_file 
    return self.get_parse_file()(file_, **kargs)
  File "/HOME/.local/lib/python3.2/site-packages/LEPL-5.0.0-py3.2.egg/lepl/core/parser.py", line 257, in single
    return next(raw(arg, **kargs))[0]
  File "/HOME/.local/lib/python3.2/site-packages/LEPL-5.0.0-py3.2.egg/lepl/core/parser.py", line 146, in trampoline 
    value = next(value.generator)
  File "/HOME/.local/lib/python3.2/site-packages/LEPL-5.0.0-py3.2.egg/lepl/lexer/lexer.py", line 133, in _match
    (max, clean_stream) = s_new_max(in_stream)
  File "/HOME/.local/lib/python3.2/site-packages/LEPL-5.0.0-py3.2.egg/lepl/stream/core.py", line 283, in <lambda>
    s_new_max = lambda stream: stream[1].new_max(stream[0])
  File "/HOME/.local/lib/python3.2/site-packages/LEPL-5.0.0-py3.2.egg/lepl/stream/core.py", line 223, in new_max
    raise NotImplementedError

----------

Original issue reported on code.google.com by wrob...@gmail.com on 26 Dec 2011 at 6:15

GoogleCodeExporter commented 9 years ago
this looks like a bug in the work done for 5.0.  i will try understand and fix 
it in the next week.  sorry.

as a work-around you might be able to use parse_iterable() on the opened file?

Original comment by acooke....@gmail.com on 1 Jan 2012 at 11:04

GoogleCodeExporter commented 9 years ago
sorry, please ignore above workaround.  looks like the problem is in the 
iterable helper (which is called from the file code).

Original comment by acooke....@gmail.com on 1 Jan 2012 at 11:26

GoogleCodeExporter commented 9 years ago
a progress report: i have fixed this particular issue (the missing new_max 
method on the iterable stream), but the example still fails because of further 
problems with the tokenizer and iterable streams.

work continues...

Original comment by acooke....@gmail.com on 6 Jan 2012 at 12:23

GoogleCodeExporter commented 9 years ago
Fixed in 5.0.1, I hope.

Original comment by acooke....@gmail.com on 8 Jan 2012 at 10:42