Changes between Initial Version and Version 1 of SomeCompilerMessages

05/13/13 12:46:39 (6 years ago)



  • SomeCompilerMessages

    v1 v1  
     1= Some Compiler Messages = 
     3A new Language and compiler can sometimes have some error messages that make little sense to beginners or tyre-kicking testers because the base critical knowledge mass for the language ( or build environment) has not yet been internalised. 
     4Hopefully thats not the case with cobra but the following are some messages that have raised questions as people begin using cobra. 
     6== Expecting DEDENT but got "..." == 
     7See ticket:316  
     9Heres the same example run from the commandline[[BR]] 
     10(this is from !Sample/BlindWatchMaker1.cobra in the source tree) 
     12> ./cobra ../Samples/BlindWatchMaker1.cobra  
     13..\Samples\BlindWatchMaker1.cobra(96,3): error: Expecting DEDENT, but got "def" instead. 
     14Compilation failed - 1 error, 0 warnings 
     15Not running due to errors above. 
     19The (broken) lines in question look like this 
     20(contents of  methods elided to show indentation)  
     23def runCumulativeSelection(goal as String, alphabet as String) as float 
     24        require 
     25                goal.length  # Pex 
     26                alphabet.length  # Pex 
     27        ensure 
     28                result > 0 
     29        body 
     30                print 'Cumulative Selection:' 
     31                start = 
     32                ... 
     33                return duration.totalSeconds 
     35        # below is line 96 
     36        def runSingleStepSelection(goal as String, alphabet as String) as float 
     37        require 
     38                goal.length 
     39                alphabet.length 
     40        ensure 
     41                result > 0 
     42        body 
     43                ... 
     47Cobra describes blocks by indentation level so language structure keywords are expected to be indented or dedented to the correct level 
     48which cobra can detect.[[BR]] 
     49In the above case the line (96) is indented an extra level ( has a spurious tab before the "def") 
     51Generally the error "Expecting DEDENT" means that the line has incorrect or unexpected indentation (i.e. too many tabs) 
     53Similar error "Expecting INDENT" means that the parser ( or language structure) is expecting an indented line or block but does not have one.  
     56 Add more as see them.