Wiki

Ticket #48: error-compiler-directive.patch

File error-compiler-directive.patch, 2.7 KB (added by hopscc, 16 years ago)
  • Source/CobraParser.cobra

     
    543543                .expect('EOL') 
    544544                # TODO: throw AssertException(SourceSite sourceSite, object[] expressions, object thiss, object info) 
    545545                assert false, IdentifierExpr(token, 'throw') 
     546            on 'error' 
     547                # emit an optional message and throw an error, halting compilation 
     548                msgText = '%%error directive' 
     549                msg = .optional('STRING_SINGLE','STRING_DOUBLE')  
     550                if msg 
     551                    msgText = msg.text[1:-1] 
     552                    print '%%> [msgText]'  
     553                .throwError('Compilation stopped: "[msgText]"') 
    546554            on 'number'   # TODO: fix this to work on a per-file basis 
    547555                # number 'decimal' | 'float' | 'float32' | 'float64' 
    548556                typeName = .grab 
  • Tests/820-errors/600-other/120-error-compiler-directive.cobra

     
     1# This tests %% error without message ends with Compilation stopped and default msg  
     2 
     3%% error  # .error. Compilation stopped: "%%error directive"  
     4class Program  
     5     
     6    def main is shared  
     7        pass 
  • Tests/820-errors/600-other/122-error-compiler-directive.cobra

     
     1# This tests %% error message ends with Compilation stopped and error msg  
     2# Need also test that provided msg emitted but need TestifyRunner i/f for that  
     3 
     4# following also emits %%> internal error 
     5%% error 'internal error' # .error. Compilation stopped: "internal error" 
     6class Program  
     7     
     8    def main is shared  
     9        pass 
  • Developer/IntermediateReleaseNotes.text

     
    11Post 0.8 
    22 
     3* Added support for a new compiler directive 'error' that takes an optional message.  
     4 When encountered in compilation of a source file it causes display of  
     5 the mesage if any and stops compilation with an error. 
     6.code 
     7    %% error 'Cannot build this file till mondo-patch installed' 
     8     
    39* Added support for "multi-arg assignment" which allows you to assign to a number of variables from contents of a list in one statement 
    410.code 
    511    a,b,c = ['val1', 'val2', 'val3']