View previous topic :: View next topic |
Author |
Message |
BLS
Joined: 28 Mar 2006 Posts: 44 Location: France
|
Posted: Tue Aug 21, 2007 8:16 am Post subject: Language EBNF / IDE Support |
|
|
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 |
|
|
csauls
Joined: 27 Mar 2004 Posts: 278
|
Posted: Tue Aug 21, 2007 2:49 pm Post subject: |
|
|
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 |
|
|
JarrettBillingsley
Joined: 20 Jun 2006 Posts: 457 Location: Pennsylvania!
|
Posted: Tue Aug 21, 2007 5:41 pm Post subject: |
|
|
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 |
|
|
|
|
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
|