in reply to Re^3: howto parse (or determining end) of a line of perl
in thread howto parse (or determining end) of a line of perl
It would be closer to what I want if you "assumed" 1 semi -- see if that parses. If so, goto next. If not, then this is where that PPI module could be useful -- run the parse w & w/o the semi and see if it only can work the 2nd way -- if so, ask for another line. If it can work w/a semi- default to closing the statement unless a backslash is on the end.
Of course if it works with or w/o a semi (like after a closing '}'), then you goback to ask for a new line.
Yours is more of a REPL (gee, wonder why!;-)), while mine was intended to print results like a calculator -- used to do a better job until I 'fixed' it some time back -- and haven't fixed it again -- printed the hex, string and fractional formats if they made sense.
BTW -- when I say 'calc', I really mean evaluate a perl expression and print the result, which was sufficient for my purposes.
It also stopped working right when my distro updated one of the Term::readchar/line routines and now it thinks it is talking to a dumb tty... real annoying, but those are 'transitory issues'... It's not something I use too much -- just now and then and now and then make changes in it -- and the "itch" of it not handling multiple lines like bash would, got "itchier", sorta, if that makes any sense.
Maybe going through the extra pain of the trying dual-parsing w/PPI and "with", and "with/out" semi's to determine whether to close input and return a result might be the shortest path to get where I might want to go, but that's too much work for a short scratching session and got bigger fish to fry before I can play in my playground...*sigh*.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: howto parse (or determining end) of a line of perl
by BrowserUk (Patriarch) on Aug 25, 2016 at 18:26 UTC | |
by perl-diddler (Chaplain) on Aug 26, 2016 at 00:40 UTC | |
by BrowserUk (Patriarch) on Aug 26, 2016 at 00:58 UTC | |
by perl-diddler (Chaplain) on Aug 26, 2016 at 14:25 UTC | |
by hippo (Archbishop) on Aug 26, 2016 at 15:12 UTC | |
|