Allow empty OUT arguments
This commit is contained in:
@@ -2161,3 +2161,11 @@ class SetX : Code
|
||||
vm.petitcomputer.xoff(func);
|
||||
}
|
||||
}
|
||||
|
||||
class Pop : Code
|
||||
{
|
||||
override void execute(VM vm)
|
||||
{
|
||||
vm.decSP();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -697,8 +697,13 @@ class Compiler
|
||||
genCode(new PopVarExpression(sc));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new SyntaxError();
|
||||
case NodeType.VoidExpression:
|
||||
{
|
||||
genCode(new Pop());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new SyntaxError();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -970,18 +970,30 @@ class Parser
|
||||
while(true)
|
||||
{
|
||||
token = lex.front();
|
||||
Expression arg = expression();
|
||||
if(!isLValue(arg))
|
||||
if (token.type == TokenType.Comma)
|
||||
{
|
||||
//to support func args... OUT (no argument)
|
||||
if (!func.outVariable.length)
|
||||
func.addOut(new VoidExpression(lex.location));
|
||||
}
|
||||
else
|
||||
{
|
||||
Expression arg = expression();
|
||||
if (!arg)
|
||||
{
|
||||
func.addOut(new VoidExpression(lex.location));
|
||||
break;
|
||||
}
|
||||
syntaxError();
|
||||
return null;
|
||||
if(!isLValue(arg))
|
||||
{
|
||||
//to support func args... OUT (no argument)
|
||||
if (!func.outVariable.length)
|
||||
{
|
||||
break;
|
||||
}
|
||||
syntaxError();
|
||||
return null;
|
||||
}
|
||||
func.addOut(arg);
|
||||
}
|
||||
func.addOut(arg);
|
||||
token = lex.front();
|
||||
if(token.type == TokenType.Comma)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user