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: chris, MtnViewMark, MtnViewJohn

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

Else clauses in switch statements don't work

Post by pakin » Sat Feb 22, 2014 1:25 am

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: 837
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 » Sat Feb 22, 2014 6:00 pm

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: 40
Joined: Sat Apr 21, 2007 8:59 pm
Location: United States
Contact:

Re: Else clauses in switch statements don't work

Post by pakin » Sat Feb 22, 2014 10:00 pm

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

Who is online

Users browsing this forum: No registered users and 1 guest