Wiki

Changes between Initial Version and Version 1 of SomeCompilerMessages

Show
Ignore:
Timestamp:
05/13/13 12:46:39 (12 years ago)
Author:
hopscc
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • SomeCompilerMessages

    v1 v1  
     1= Some Compiler Messages = 
     2 
     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. 
     5 
     6== Expecting DEDENT but got "..." == 
     7See ticket:316  
     8 
     9Heres the same example run from the commandline[[BR]] 
     10(this is from !Sample/BlindWatchMaker1.cobra in the source tree) 
     11{{{ 
     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. 
     16> 
     17}}} 
     18 
     19The (broken) lines in question look like this 
     20(contents of  methods elided to show indentation)  
     21{{{ 
     22... 
     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 = DateTime.now 
     32                ... 
     33                return duration.totalSeconds 
     34 
     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                ... 
     44 
     45}}} 
     46 
     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") 
     50 
     51Generally the error "Expecting DEDENT" means that the line has incorrect or unexpected indentation (i.e. too many tabs) 
     52 
     53Similar error "Expecting INDENT" means that the parser ( or language structure) is expecting an indented line or block but does not have one.  
     54 
     55---------------------------- 
     56 Add more as see them.