Changeset 1570 for cobra/trunk/Source/CobraTokenizer.cobra
- Timestamp:
- 08/06/08 21:46:58 (5 months ago)
- Files:
-
- 1 modified
-
cobra/trunk/Source/CobraTokenizer.cobra (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cobra/trunk/Source/CobraTokenizer.cobra
r1549 r1570 51 51 var _inSubstStringDouble = false 52 52 var _inDocString = false 53 var _inCommentBlock = false 53 54 54 55 def init … … 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, … … 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]+', … … 381 384 return nil 382 385 386 ## 387 ## Comment out block 388 ## 389 390 var _commentBlockStop as TokenRegexDef? 391 var _commentBlockLine as TokenRegexDef? 392 393 def onCOMMENT_BLOCK_START(tok as IToken) as IToken? 394 #print '<> onCOMMENT_BLOCK_START', tok 395 assert not _inCommentBlock 396 # narrow the tokenizer's token defs to a new shorter set 397 if _commentBlockStop is nil 398 _commentBlockStop = TokenRegexDef('COMMENT_BLOCK_STOP', r'[^# \t]?\#\/.*$') 399 _commentBlockLine = TokenRegexDef('COMMENT_BLOCK_LINE', '.*\n') 400 t = List<of TokenDef>() 401 t.add(_commentBlockStop) 402 t.add(_commentBlockLine) 403 .pushTokenDefs(t) 404 _inCommentBlock = true 405 return nil 406 407 def onCOMMENT_BLOCK_LINE(tok as IToken) as IToken? 408 #print '<> onCOMMENT_BLOCK_LINE', tok.lineNum 409 assert _inCommentBlock, tok 410 return nil 411 412 def onCOMMENT_BLOCK_STOP(tok as IToken) as IToken? 413 #print '<> onCOMMENT_BLOCK_STOP', tok.lineNum 414 assert _inCommentBlock, tok 415 _inCommentBlock = false 416 .popTokenDefs 417 return nil 418 383 419 def onINDENT_MIXED_TSNS(tok as IToken) as IToken? 384 420 # expecting tabs, spaces, non-whitespace
