Changeset 1572

Show
Ignore:
Timestamp:
08/11/08 06:44:56 (3 months ago)
Author:
Chuck.Esterbrook
Message:

Added support for /# inline #/ comments.

Location:
cobra/trunk
Files:
2 added
2 modified

Legend:

Unmodified
Added
Removed
  • cobra/trunk/Developer/IntermediateReleaseNotes.text

    r1571 r1572  
    11Post 0.8 
    22 
    3 * Add support for commenting full blocks of lines using /# and #/. Block comments can be nested. 
    4         '/#' block comment start and  '#/' block comment end as initial chars on line 
     3* Added new comment markers /# ... #/ which can be used for block comments and inline comments. Block comments must start at the beginning of a line and can be used to comment out multiple lines of source. They can be nested. Inline comments also start with /# and end with #/, but within the same line. They can be used to comment out a portion of a line. Regular end of line comments are still available and still the norm. 
     4.code 
     5        class Example 
     6         
     7                def main is shared 
     8                        # an end-of-line comment 
     9                        t = [1, 2, 3]  # a list of numbers 
     10 
     11                        # an inline comment 
     12                        print t, /#t[0],#/ t.count 
     13 
     14                        # a block comment 
     15        /# 
     16                def foo 
     17                        print 'bar' 
     18        #/ 
    519 
    620* Added support for a Cobra compiler directive to specify the type for `number` 
  • cobra/trunk/Source/CobraTokenizer.cobra

    r1571 r1572  
    8686                        r'NO_INDENT                             ^(?=[^\t\n#\/])', 
    8787                        r'EOL                                   \n', 
     88                        r'INLINE_COMMENT                \/\#.*\#/', 
    8889                        r'COMMENT_BLOCK_START   ^\/\#.*$',   
    8990                        r'SINGLE_LINE_COMMENT   \#.*', 
     91                        r'AMBIGUOUS_COMMENT             \/\#.*', 
    9092                        r'SPACE                                 [ \t]+', 
    9193 
     
    509511                return nil 
    510512 
     513        def onINLINE_COMMENT(tok as IToken) as IToken? 
     514                # eat these 
     515                return nil 
     516 
     517        def onAMBIGUOUS_COMMENT(tok as IToken) as IToken? 
     518                .throwError('Ambiguous comment at /#. For an end-of-line comment, put a space between / and #. For an inline comment, end it with #/. For a block comment, put /# at the beginning of a line.') 
     519                return nil 
     520 
    511521        def onSPACE(tok as IToken) as IToken? 
    512522                # eat these