esainane / pyp

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

cmds_split produces incorrect results with relation to backslashes, doesn't deal with [] or {} brackets #17

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I originally borrowed the implementation of pyp's `cmds_split` function for my 
pyp-inspired `piep` tool. I recently found some cases where this function 
doesn't break up strings properly, so I rewrote the function until it passed, 
and thought you might be interested in the results (or at least the test cases).

There is probably a less-dramatic change to get everything working, but I 
suspect it's hard to understand this function until you write it yourself ;)

https://github.com/gfxmonk/piep/commit/0bbdcc4cedd351fb4472945ffcd38633eab1e322

(note the doctests, which don't pass in `pyp`)

Original issue reported on code.google.com by gfxm...@gmail.com on 16 Aug 2012 at 12:35

GoogleCodeExporter commented 8 years ago
interesting. I'll have to check it out. Is it possible to somehow compact it? 
It's already a fairly long function...is there a more succinct way of doing 
this? Thanks for your input! 

Original comment by tobyro...@gmail.com on 22 Aug 2012 at 6:27

GoogleCodeExporter commented 8 years ago
A friend of mine had a go at condensing the logic - it's still the same basic 
algorithm (I don't think that can be made much simpler), but is now a little 
shorter. Not sure if that helps, but it's a bit easier to follow now as well:

https://github.com/gfxmonk/piep/blob/master/piep/main.py#L147

Original comment by gfxm...@gmail.com on 22 Aug 2012 at 10:14

GoogleCodeExporter commented 8 years ago
ok, cool. we'll check that out. thanks for working on this.

Original comment by tobyro...@gmail.com on 5 Sep 2012 at 6:46

GoogleCodeExporter commented 8 years ago
I like the compactness of the second example. Do you guys have some examples of 
how pyp fails with real world text? I see your unit tests, but we haven't 
really encountered that kind of parsing here.

Thanks!

Original comment by tobyro...@gmail.com on 1 Feb 2013 at 5:32

GoogleCodeExporter commented 8 years ago
I'm afraid it's been too long, I didn't keep any examples that failed (although 
I definitely encountered one in regular, that's how I found the bug). I assumed 
the unit tests were sufficient to show that the code was buggy...

Original comment by gfxm...@gmail.com on 1 Feb 2013 at 11:33