Ticket #42: string-termin2.patch
File string-termin2.patch, 3.1 KB (added by hopscc, 15 years ago) |
---|
-
Source/BackEndClr/SharpGenerator.cobra
3749 3749 3750 3750 get asSharp as String is override 3751 3751 return Utils.sharpStringLiteralFor(_string) 3752 3753 def writeSharpDef(sw as CurlyWriter, parens as bool) is override 3754 if _string.contains(sharp'"\u2028"') # unicode line seperator 3755 _expandPlatformNewline(sw) 3756 return 3752 3757 3753 3758 s = .asSharp 3759 sw.write(s) 3760 3761 def _expandPlatformNewline(sw as CurlyWriter) 3762 ucodeLineSep as char = sharp"'\u2028'" 3763 l = List<of String>(_string.split( @[ucodeLineSep] )) 3764 if l.count == 1 # false alarm no \N 3765 sw.write(.asSharp) 3766 return 3767 3768 sep = '' 3769 sw.write('CobraLangInternal.CobraImp.MakeString(') 3770 for s0 in l[:-1] 3771 sw.write(sep) 3772 sw.write(Utils.sharpStringLiteralFor(s0)) 3773 sw.write(',CobraLangInternal.CobraImp._printStringMaker.MakeString(Cobra.Lang.CobraCore.NewLine)') 3774 sep = ',' 3775 sw.write(sep) 3776 sw.write(Utils.sharpStringLiteralFor(l.last)) 3777 sw.write(')') 3778 3754 3779 class StringSubstLit 3755 3780 is partial 3756 3781 -
Source/CobraTokenizer.cobra
705 705 # cannot have `last` being a backslash anymore--it's considered consumed now 706 706 last = c'\0' 707 707 continue 708 on c'N' # platfrom indep line termin 709 #chars.append(Environment.newLine) 710 chars.append(sharp"'\u2028'") # unicode line separator 708 711 else, next = c # TODO: should probably be error: Invalid escape sequence 709 712 else if c<>'\\' 710 713 next = c -
Tests/100-basics/068-string-termin.cobra
1 # Test for platform independent line terminator in strings 2 class Test 3 def main is shared 4 assert "\N" == Environment.newLine 5 assert '\N' == Environment.newLine 6 s = "\\N" 7 assert not s == Environment.newLine 8 assert s.length == 2 9 assert s == r'\N' 10 assert not r'\N' == Environment.newLine 11 12 n=0 13 nl = Environment.newLine 14 assert '=[n]\N' == '=0[nl]' 15 assert '=[n]=[n+1]=\N' == '=0=1=[nl]' -
Developer/IntermediateReleaseNotes.text
48 48 49 49 * Sets with duplicate members such as `{1, 0, 1}` now generate a warning. 50 50 51 * Add support for \N metacharacter in strings for platform-sensitive line terminator. ticket:42 52 51 53 ================================================================================ 52 54 Library 53 55 ================================================================================