Changeset 1579

Show
Ignore:
Timestamp:
08/14/08 07:36:30 (3 months ago)
Author:
Chuck.Esterbrook
Message:

Code cleanup/fix: Make comment-directive checking take place on lines with only a comment (no code).

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • cobra/trunk/Source/CobraTokenizer.cobra

    r1578 r1579  
    390390        def onWHITESPACE_COMMENT_1(tok as IToken) as IToken? 
    391391                #print '<> onWHITESPACE_COMMENT_1' 
     392                .checkForCommentDirective(tok) 
    392393                return nil 
    393394 
    394395        def onWHITESPACE_COMMENT_2(tok as IToken) as IToken? 
    395396                #print '<> onWHITESPACE_COMMENT_2' 
     397                .checkForCommentDirective(tok) 
    396398                return nil 
    397399         
     
    510512                return tok 
    511513 
    512         var _directiveRE = Regex(r'#\s?\.([\w\-]+)\.($|\s)', RegexOptions.Compiled) 
    513  
    514514        def onSINGLE_LINE_COMMENT(tok as IToken) as IToken? 
    515515                # eat these 
    516                  
    517                 # check for .no-warnings. 
    518                 reMatch = _directiveRE.match(tok.text) 
    519                 if reMatch.success 
    520                         name = reMatch.groups[1].value 
    521                         branch name 
    522                                 on 'no-warnings', .addNoWarning(tok) 
    523                                 # for testify 
    524                                 on 'args', pass  # TODO: actually this could be worth implementing outside of testify 
    525                                 on 'compile-only', pass 
    526                                 on 'error', pass 
    527                                 on 'multi', pass 
    528                                 on 'multipart', pass 
    529                                 on 'skip', pass 
    530                                 on 'warning', pass 
    531                                 else, .throwError('Unrecognized compiler directive "[name]".') 
    532  
     516                .checkForCommentDirective(tok) 
    533517                return nil 
    534518 
     
    935919 
    936920        ## 
     921        ## Self util 
     922        ## 
     923 
     924        var _directiveRE = Regex(r'#\s?\.([\w\-]+)\.($|\s)', RegexOptions.Compiled) 
     925 
     926        def checkForCommentDirective(tok as IToken) 
     927                # check for .no-warnings. 
     928                reMatch = _directiveRE.match(tok.text) 
     929                if reMatch.success 
     930                        name = reMatch.groups[1].value 
     931                        branch name 
     932                                on 'no-warnings', .addNoWarning(tok) 
     933                                # for testify 
     934                                on 'args', pass  # TODO: actually this could be worth implementing outside of testify 
     935                                on 'compile-only', pass 
     936                                on 'error', pass 
     937                                on 'multi', pass 
     938                                on 'multipart', pass 
     939                                on 'skip', pass 
     940                                on 'warning', pass 
     941                                else, .throwError('Unrecognized compiler directive "[name]".') 
     942 
     943 
     944        ## 
    937945        ## Deprecated 
    938946        ##