diff --git a/SMILEBASIC/VM.d b/SMILEBASIC/VM.d index 10d3d41..fd06259 100644 --- a/SMILEBASIC/VM.d +++ b/SMILEBASIC/VM.d @@ -2161,3 +2161,11 @@ class SetX : Code vm.petitcomputer.xoff(func); } } + +class Pop : Code +{ + override void execute(VM vm) + { + vm.decSP(); + } +} diff --git a/SMILEBASIC/compiler.d b/SMILEBASIC/compiler.d index b45b538..c9d997c 100644 --- a/SMILEBASIC/compiler.d +++ b/SMILEBASIC/compiler.d @@ -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(); } } diff --git a/SMILEBASIC/parser.d b/SMILEBASIC/parser.d index f2d1c82..5e3d0fa 100644 --- a/SMILEBASIC/parser.d +++ b/SMILEBASIC/parser.d @@ -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) {