easy partial support for regexp -expanded #311
Replies: 9 comments 3 replies
-
Deleting also tabs, newlines, and other whitespace-class characters in the same pass is also a good idea. Then we can have multi-line regex's, which is occasionally useful for legibility. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the feedback and the suggestion. I pushed something to master-next that you can try |
Beta Was this translation helpful? Give feedback.
-
Huzzah!!! I tested that. It's great!! Spaces, newlines, tabs, comments all worked the way you intended in regexp (i looked at the source). I didn't test regsub. And it's even documented! THANK YOU!!! This has pestered me for YEARS, ever since the first week i used jimsh. Along the way I also noticed in action several of the other improvements of this year. Excellent!! One question. In this part:
What case is that for? It wasn't obvious what its effect is. |
Beta Was this translation helpful? Give feedback.
-
Here are some
|
Beta Was this translation helpful? Give feedback.
-
sure, i'll look in the test suite and see if that change is practical for me... |
Beta Was this translation helpful? Give feedback.
-
Maybe someone here can help with a problem I'm having trying to use https://github.com/devnull42/fickle with jimtcl it seems to be related with this topic because it does work with tclsh. When trying to generate a scanner for this example https://github.com/devnull42/taccle/blob/master/examples/simple_scanner.fcl I'm getting this error:
The offending line is this one:
I'm a beginer with tcl . |
Beta Was this translation helpful? Give feedback.
-
I don't know anything about fickle, but the problem seems to be using |
Beta Was this translation helpful? Give feedback.
-
And this has nothing to do with regexp -expanded |
Beta Was this translation helpful? Give feedback.
-
I created an issue for you: #323 |
Beta Was this translation helpful? Give feedback.
-
<gush>
Been using jimsh every day for many years. It's clearly the ultimate evolution of Tcl. It should just be mainstreamed on tcl.tk instead of tclsh.</gush>
But, I used regexp -expanded all the time in tclsh (such as #310 (comment)).
jimsh never had it, and I can see why.
But every time I use any regexp, I have to start like this:
set re [string map {{ } {}} { ^ \s* (\S+) \s+ (\w+) \s+ (\d+ \. \d+ \. \d+ \. \d+ / \d+)+ \s* }]
That adds a LOT of braces and loss of legibility in order to write an expression that's supposed to have GREATER legibility. One step forward, two steps back.
I propose an easy solution: support
regexp -expanded
which simply deletes all the spaces, as in my example. Don't bother with the comment feature offered by the same option in tclsh. I've never needed it.That solution should run fast as well. Much faster than my example. And not add much executable size at all.
And it doesn't have to be called
-expanded
. There's an argument for avoiding that since the feature isn't identical to tclsh. So it would be fine to call it something else, like-compress
. But not having it at all is a real nuisance.If you can't make time for this, I understand. My life is crazy right now, but I might be able to make time for this small PR.
Beta Was this translation helpful? Give feedback.
All reactions