FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Language EBNF / IDE Support

 
Post new topic   Reply to topic     Forum Index -> MiniD
View previous topic :: View next topic  
Author Message
BLS



Joined: 28 Mar 2006
Posts: 44
Location: France

PostPosted: Tue Aug 21, 2007 8:16 am    Post subject: Language EBNF / IDE Support Reply with quote

Hi I am just working on IDE Support for MiniD (NetBeans)

So I have to translate your EBNF a bit and need some support regarding the CaseStatement

Code:

SwitchStatement:
   'switch' '(' Expression ')' '{' CaseStatement {CaseStatement} [DefaultStatement] '}'

CaseStatement:
   'case' Expression {',' Expression} ':' {Statement}
   
DefaultStatement:
   'default' ':' {Statement}




Does this mean :
Code:

switch x
case  a, b, c   

is Legal ?

Same question regarding the returnStatement which is similar defined ;

return a,b,u,v     // quit unusual

is legal ?





Bjoern
Back to top
View user's profile Send private message
csauls



Joined: 27 Mar 2004
Posts: 278

PostPosted: Tue Aug 21, 2007 2:49 pm    Post subject: Reply with quote

I can actually answer the second part: yes, you can return multiple values.

I would assume the 'case a,b,c' is also legal. Its actually legal in D as well, as I recall. But I'll let Jarrett answer it as I don't think I've ever tried it.
_________________
Chris Nicholson-Sauls
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
JarrettBillingsley



Joined: 20 Jun 2006
Posts: 457
Location: Pennsylvania!

PostPosted: Tue Aug 21, 2007 5:41 pm    Post subject: Reply with quote

It is indeed legal. "case a, b, c:" is, just like in D, equivalent to "case a: case b: case c:".

And yes, multiple return values are legal. So is multiple assignment:

Code:

function f()
{
    return 1, 2, 3;
}

local a, b, c;
a, b, c = f();
writeln("{}, {}, {}", a, b, c); // prints 1, 2, 3


This is a feature taken from Lua.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> MiniD All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group