| 1 | = Some Compiler Messages = |
| 2 | |
| 3 | 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. |
| 4 | Hopefully 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 "..." == |
| 7 | See ticket:316 |
| 8 | |
| 9 | Heres 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. |
| 14 | Compilation failed - 1 error, 0 warnings |
| 15 | Not running due to errors above. |
| 16 | > |
| 17 | }}} |
| 18 | |
| 19 | The (broken) lines in question look like this |
| 20 | (contents of methods elided to show indentation) |
| 21 | {{{ |
| 22 | ... |
| 23 | def 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 | |
| 47 | Cobra describes blocks by indentation level so language structure keywords are expected to be indented or dedented to the correct level |
| 48 | which cobra can detect.[[BR]] |
| 49 | In the above case the line (96) is indented an extra level ( has a spurious tab before the "def") |
| 50 | |
| 51 | Generally the error "Expecting DEDENT" means that the line has incorrect or unexpected indentation (i.e. too many tabs) |
| 52 | |
| 53 | Similar 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. |