Some Compiler Messages
A 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. Hopefully thats not the case with cobra but the following are some messages that have raised questions as people begin using cobra.
Expecting DEDENT but got "..."
Heres the same example run from the commandline
(this is from Sample/BlindWatchMaker1.cobra in the source tree)
> ./cobra ../Samples/BlindWatchMaker1.cobra ..\Samples\BlindWatchMaker1.cobra(96,3): error: Expecting DEDENT, but got "def" instead. Compilation failed - 1 error, 0 warnings Not running due to errors above. >
The (broken) lines in question look like this (contents of methods elided to show indentation)
... def runCumulativeSelection(goal as String, alphabet as String) as float require goal.length # Pex alphabet.length # Pex ensure result > 0 body print 'Cumulative Selection:' start = DateTime.now ... return duration.totalSeconds # below is line 96 def runSingleStepSelection(goal as String, alphabet as String) as float require goal.length alphabet.length ensure result > 0 body ...
Cobra describes blocks by indentation level so language structure keywords are expected to be indented or dedented to the correct level
which cobra can detect.
In the above case the line (96) is indented an extra level ( has a spurious tab before the "def")
Generally the error "Expecting DEDENT" means that the line has incorrect or unexpected indentation (i.e. too many tabs)
Similar error "Expecting INDENT" means that the parser ( or language structure) is expecting an indented line or block but does not have one.
Add more as see them.