Else clauses in switch statements don't work

If you're having trouble using Context Free or don't understand the language, ask for help here.

Moderators: MtnViewJohn, chris, mtnviewmark

Post Reply
User avatar
pakin
Posts: 43
Joined: Sat Apr 21, 2007 8:59 pm
Location: United States
Contact:

Else clauses in switch statements don't work

Post 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

User avatar
MtnViewJohn
Site Admin
Posts: 882
Joined: Fri May 06, 2005 2:26 pm
Location: Mountain View, California
Contact:

Re: Else clauses in switch statements don't work

Post 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.

User avatar
pakin
Posts: 43
Joined: Sat Apr 21, 2007 8:59 pm
Location: United States
Contact:

Re: Else clauses in switch statements don't work

Post 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

Post Reply