Page 2 of 3
Re: Escaping substitution in strings
Posted:
Mon Apr 28, 2008 8:08 am
by hopscc
Heres another patch for escaped substitution in strings - this one using a TokenDef subclass and an extension to the straight re matching
Its a little more widespread than desirable due the .Net Match class being immutable and not exposing a public constructor -
I had to wrap it and change the baseclass return type and consequent changes
Re: Escaping substitution in strings
Posted:
Mon Apr 28, 2008 9:53 am
by Charles
I'll take a look this week. Thanks.
Re: Escaping substitution in strings
Posted:
Wed Apr 30, 2008 7:21 am
by Steve
Would it be possible to offer an alternative syntax that is a little more unique than [ ]? For instance, in Boo I believe the syntax was ${ }, which was unique enough that I never had any problems. The current syntax that Cobra uses seems to occur quite frequently unfortunately.
Best regards as always,
Steve
Re: Escaping substitution in strings
Posted:
Thu May 01, 2008 9:15 am
by Charles
Let's start with the escaping of brackets with \ and raw strings, and go from there.
Re: Escaping substitution in strings
Posted:
Fri May 09, 2008 12:37 am
by Charles
In development, you can now escape a square bracket with a backslash to prevent Cobra from interpreting it as a substitution expression:
assert 'foo \[bar]' == r'foo [bar]'
Re: Escaping substitution in strings
Posted:
Fri May 09, 2008 5:46 am
by hopscc
Good changes.
Theres one edge case it misses - escaped escape
- Code: Select all
a=99
assert "s2:a=\\[a]" == r"s2:a=\99"
Re: Escaping substitution in strings
Posted:
Fri May 09, 2008 5:47 am
by hopscc
Heres the test file
Re: Escaping substitution in strings
Posted:
Sun May 11, 2008 2:39 pm
by Charles
Thanks, these are good test cases. I even had them in my workspace already from when you first posted them, but in my last work session, I forgot about them!
Cases added. Bug fixed.
Re: Escaping substitution in strings
Posted:
Wed May 14, 2008 5:49 am
by hopscc
and finally... heres a patch to remove the mostly duplicated code in each of the new
StringTokenDef subclasses match methods
Re: Escaping substitution in strings
Posted:
Tue Jun 03, 2008 1:24 am
by Charles
I'm unable to apply this patch:
- Code: Select all
patch -p0 -i rmdupcode.patch
patching file CobraTokenizer.cobra
patch: **** malformed patch at line 14: @@ -743,6 +773,25 @@
I tried on Windows and then on Mac with the same result. The command "patch -p0 -i <file>" has worked in the past and I'm not sure what is wrong.
Did you use the "svn di" command as explained at
http://cobra-language.com/trac/cobra/wiki/HowToSubmitAPatch. If so, what version of svn are you on?
I could do this small patch by hand, but let's find out what's going wrong.
-Chuck