Ticket #20: blockComment1.patch
File blockComment1.patch, 4.9 KB (added by hopscc, 16 years ago) |
---|
-
Source/CobraTokenizer.cobra
50 50 var _inSubstStringSingle = false 51 51 var _inSubstStringDouble = false 52 52 var _inDocString = false 53 var _inCommentBlock = false 53 54 54 55 def init 55 56 base.init … … 65 66 sb.append('_inSubstStringSingle=[_inSubstStringSingle], ') 66 67 sb.append('_inSubstStringDouble=[_inSubstStringDouble], ') 67 68 sb.append('_inDocString=[_inDocString]') 69 sb.append('_inCommentBlock=[_inCommentBlock]') 68 70 69 71 # Note: The Tokenizer class handles it's input one line at a time, 70 72 # and retains the \n at the end of the line. This affects … … 81 83 r'INDENT_MIXED_ST ^[ ]+[\t]+', 82 84 r'INDENT_ALL_TABS ^[\t]+', 83 85 r'INDENT_ALL_SPACES ^[ ]+', 84 r'NO_INDENT ^(?=[^\t\n# ])',86 r'NO_INDENT ^(?=[^\t\n#\/])', 85 87 r'EOL \n', 88 r'COMMENT_BLOCK_START ^\/\#.*$', 86 89 r'SINGLE_LINE_COMMENT \#.*', 87 90 r'SPACE [ \t]+', 88 91 89 92 r'OPEN_GENERIC [A-Za-z_][A-Za-z0-9_]*<of[ \n\r\t]', 90 93 r'OPEN_IF if\(', 91 94 r'OPEN_CALL [A-Za-z_][A-Za-z0-9_]*\(', … … 380 383 #print '<> onWHITESPACE_COMMENT_2' 381 384 return nil 382 385 386 ## 387 ## Comment out block 388 ## 389 def onCOMMENT_BLOCK_START(tok as IToken) as IToken? 390 #print '<> onCOMMENT_BLOCK_START', tok.lineNum 391 assert not _inCommentBlock 392 # narrow the tokenizer's token defs to a new shorter set 393 # TODO: cache the tokens below 394 t = List<of TokenDef>() 395 t.add(TokenRegexDef('COMMENT_BLOCK_STOP', r'[^# \t]?\#\/.*$')) 396 t.add(TokenRegexDef('COMMENT_BLOCK_LINE', '.*\n')) 397 .pushTokenDefs(t) 398 _inCommentBlock = true 399 return nil 400 401 def onCOMMENT_BLOCK_LINE(tok as IToken) as IToken? 402 #print '<> onCOMMENT_BLOCK_LINE', tok.lineNum 403 assert _inCommentBlock, tok 404 return nil 405 406 def onCOMMENT_BLOCK_STOP(tok as IToken) as IToken? 407 #print '<> onCOMMENT_BLOCK_STOP', tok.lineNum 408 assert _inCommentBlock, tok 409 _inCommentBlock = false 410 .popTokenDefs 411 return nil 412 383 413 def onINDENT_MIXED_TSNS(tok as IToken) as IToken? 384 414 # expecting tabs, spaces, non-whitespace 385 415 assert tok.text.startsWith('\t') … … 817 847 def onDOC_STRING_BODY_TEXT(tok as IToken) as IToken 818 848 assert _inDocString, tok 819 849 return tok 820 821 850 822 851 ## 823 852 ## Simple string literals 824 853 ## -
Tests/100-basics/018-multiline-comment.cobra
1 # Testing multiline/block comments - /# and #/ on SOL 2 namespace Test 3 /# 1 4 This section won't compile if uncommented 5 a comment line 6 another comment line 7 x=55 + 2 8 }#/ 9 10 class Test 11 /# 2 12 _foo as int = 9 is shared 13 _bar as String is shared 14 #/ 15 var foo1 as int = 9 16 is shared, private 17 18 19 /#{ 3 20 a comment TAB 21 # a comment SPACE TAB 22 # a comment TAB SPACE 23 # a comment 4 SPACEs 24 # a comment 5 SPACEs 25 }#/ 26 def main is shared 27 a = 1 28 /# 29 # test 30 a += 1 31 a += 1 32 assert a==3 33 a += _foo 34 #/ 35 assert a==1 36 37 a = .foo1 38 assert a == 9 # resolve to class var 39 40 a = .x 41 assert a == 99 42 43 a = .x1 44 assert a == 48 45 return 46 47 def x as int is shared 48 ret=99 49 /#{ ret += 1 50 ret += 1 51 #/ ret += 1 # rest of line after block comment termin ignored 52 return ret 53 54 /# 55 def foo1 as in is shared 56 return 99 57 #/ 58 /# # Comment out a method 59 def whatTimeIsLove is shared 60 return nil 61 #/ 62 63 def x1 as int is shared 64 a =47 65 /# 66 # comment across 2 methods 67 68 a += 1 69 return a 70 71 def x2 is shared 72 a = 48 73 a += 2 74 #/ 75 76 a += 1 77 return a 78 79 /# 80 81 interface Stringy 82 def toStringX 83 84 class String 85 implements Stringy 86 _s 87 88 def init() 89 _s = 'xxxx' 90 91 def toString 92 return _s 93 94 #/ 95 96 /# 97 test 98 /# these dont nest 99 assert _foo == 9 100 # / 101 assert _bar is nil 102 #/ 103 -
Developer/IntermediateReleaseNotes.text
1 1 Post 0.8 2 2 3 * Add support for commenting full blocks of lines 4 '/#' block comment start and '#/' block comment end as initial chars on line 5 3 6 * Added a new built-in doc tool accessible via "cobra -doc ...". The documentation is generated to local HTML files using your declarations, doc strings, contracts, etc. 4 7 5 8 * Added support for declaring and raising events.