To view this discussion on the web visit https://groups.google.com/d/msg/lepl/-/qhLlkko94bIJ.Andrew--
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.
Anyway, I ran your code, and what is happening in the second case is that you
are trying to find the position of an exhausted stream. I realise that it
should do something more useful, like return one past the end of the file, or
-1 or something (it might do so if you're not using tokens), and I'll fix it
for the next release (which is still a lot of work away). But for now a
simple fix would be:
class Block(List): pass
def with_line(node):
def wrapper(results, stream_in, stream_out):
print('inside')
a = s_delta(stream_in)[1]
try:
b = s_delta(stream_out)[1]
except StopIteration:
b = 'eof'
return node([results, a, b])
return wrapper
identifier = Token('[a-zA-Z][a-zA-Z0-9_]*') > List
symbol = Token('[^0-9a-zA-Z \t\r\n]')
#block = (~symbol('{') & (identifier | symbol)[0:] ** with_line(Block) &
~symbol('}')) # V1
block = (~symbol('{') & (identifier | symbol)[0:] & ~symbol('}')) **
with_line(Block) # V2
parser = block.get_parse()
print(parser('{\n Andrew \n}')[0])
cheers,
andrew
> > > > at https://groups.google.com/d/msg/lepl/0nsdsTH_bXI/rG5PR57sk1wJyou'll