Page 1 of 1

Else clauses in switch statements don't work

Posted: Sat Feb 22, 2014 1:25 am
by pakin
I can't get else clauses in switch statements to work (cfdg 3.0.6(v22), 64-bit Linux):

Code: Select all

startshape badness

shape badness {
  switch (randint(3)) {
    case 1:
      SQUARE [ ]
    case 2:
      CIRCLE [ ]
    else:
      TRIANGLE [ ]
  }
}
This gives me an

Code: Select all

Error in bad.cfdg at line 9 - syntax error
error. Is my code wrong? Is the CFDG documentation wrong? Is there a bug in the cfdg program itself?

Thanks,
— Scott

Re: Else clauses in switch statements don't work

Posted: Sat Feb 22, 2014 6:00 pm
by MtnViewJohn
It is a bug in the parser. 'else:' is being parsed differently than 'else :'. Just put a space before the colon until I fix it.

Re: Else clauses in switch statements don't work

Posted: Sat Feb 22, 2014 10:00 pm
by pakin
MtnViewJohn wrote:It is a bug in the parser. 'else:' is being parsed differently than 'else :'. Just put a space before the colon until I fix it.
That works; thanks.

— Scott