Changeset 1584
- Timestamp:
- 08/19/08 05:43:00 (3 months ago)
- Location:
- cobra/trunk/Source
- Files:
-
- 3 modified
-
Boxes.cobra (modified) (1 diff)
-
CobraParser.cobra (modified) (1 diff)
-
Utils.cobra (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cobra/trunk/Source/Boxes.cobra
r1583 r1584 318 318 319 319 # eliminate duplicates 320 # CC: suggs = List<of String>(Set<of String>(suggs)) 321 d = Dictionary<of String, int>() 322 for sugg in suggs 323 d[sugg] = 1 324 suggs = List<of String>(d.keys) 325 320 suggs = List<of String>(Set<of String>(suggs)) 326 321 suggs.sort 327 322 328 323 # okay to sort by alpha, but if a name differs only by case, put it up front 329 324 lowerName = name.toLower 330 for i = 0 ..suggs.count325 for i in suggs.count 331 326 if suggs[i].toLower == lowerName 332 327 sugg = suggs[i] -
cobra/trunk/Source/CobraParser.cobra
r1583 r1584 28 28 return true 29 29 30 # CC: get fileName from var is override 31 get fileName as String is override 32 return _fileName 33 34 # CC: get lineNum from var is override 35 get lineNum as int is override 36 return _lineNum 30 get fileName from var is override 31 32 get lineNum from var is override 37 33 38 34 -
cobra/trunk/Source/Utils.cobra
r1583 r1584 9 9 extend String 10 10 11 /# 12 CC: parser error, this won''t fly: 11 13 def capped as String 12 return Utils.capped(this) 13 14 """ 15 Returns the string with the first character capitalized. 16 Returns a blank string for a blank string. 17 """ 18 # CC: contracts on extension methods 19 # ensure 20 # result.length == .length 21 # result.length implies result[0] == result[0].toUpper 22 test 23 assert 'chuck'.capped == 'Chuck' 24 assert 'Chuck'.capped == 'Chuck' 25 assert ''.capped == '' 26 assert ' foo'.capped == ' foo' 27 assert 'f'.capped == 'F' 28 assert '1aoeu'.capped == '1aoeu' 29 body 30 if .length == 0, return this 31 return this[0:1].toUpper + this[1:] 32 #/ 33 34 def capped as String 35 """ 36 Returns the string with the first character capitalized. 37 Returns a blank string for a blank string. 38 """ 39 test 40 assert 'chuck'.capped == 'Chuck' 41 assert 'Chuck'.capped == 'Chuck' 42 assert ''.capped == '' 43 assert ' foo'.capped == ' foo' 44 assert 'f'.capped == 'F' 45 assert '1aoeu'.capped == '1aoeu' 46 body 47 if .length == 0, return this 48 return this[0:1].toUpper + this[1:] 14 49 15 50 class Utils … … 28 63 29 64 def normalizePath(path as String) as String 30 # TODO: this needs cleanup 31 while path.startsWith('.\\') 32 path = path.substring(2) 33 while path.startsWith('./') 34 path = path.substring(2) 65 while path.startsWith('.\\'), path = path[2:] 66 while path.startsWith('./'), path = path[2:] 35 67 return path 36 68 … … 48 80 # Could be made more sophisitcated in the future 49 81 return name + 's' 50 51 def capped(s as String) as String52 """53 Returns the string with the first character capitalized.54 Returns a blank string for a blank string.55 """56 ensure57 result.length == s.length58 result.length implies result[0] == result[0].toUpper59 test60 assert Utils.capped('chuck')=='Chuck'61 assert Utils.capped('Chuck')=='Chuck'62 assert Utils.capped('')==''63 assert Utils.capped(' foo')==' foo'64 assert Utils.capped('f')=='F'65 assert Utils.capped('1aoeu')=='1aoeu'66 body67 if s.length==068 return s69 return s[0:1].toUpper + s[1:]70 82 71 83 def isCapped(s as String) as bool
