]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
return assignment factorial test
authorWolfgang Bumiller <wry.git@bumiller.com>
Wed, 29 May 2013 14:58:18 +0000 (16:58 +0200)
committerWolfgang Bumiller <wry.git@bumiller.com>
Wed, 29 May 2013 14:58:18 +0000 (16:58 +0200)
parser.c
tests/rassign.qc
tests/rassign.tmpl

index 27c694d406955059e8400eb121c4dfb223734186..d9be036927c38ab3608613db3c7d2bc3b18961e6 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -2955,6 +2955,11 @@ static bool parse_return(parser_t *parser, ast_block *block, ast_expression **ou
             return false;
         }
 
+        if (parser->tok != ';')
+            parseerror(parser, "missing semicolon after return assignment");
+        else if (!parser_next(parser))
+            parseerror(parser, "parse error after return assignment");
+
         *out = var;
         return true;
     }
index 7e3d0e61f1b24cb5ace0b225081d7c2c50aa35c5..69ec31cf9017ff0a18c361bddbbae4c2170fefb8 100644 (file)
@@ -9,7 +9,7 @@ vector f_vector() {
     foo.x = f_float();
     foo.y = f_float();
     foo.z = f_float();
-    
+
     return = foo;
     return;
 }
@@ -20,8 +20,16 @@ string f_string() {
     return;
 }
 
+float factorial(float n) {
+    if (n == 0) return = 1;
+    else        return = n * factorial(n - 1);
+
+    return;
+}
+
 void main() {
     print(ftos(f_float()), "\n");  // 200.0f
     print(vtos(f_vector()), "\n"); // '1 2 3'
     print(f_string(), "\n");       // world
+    print(ftos(factorial(4)), "\n"); // 24
 }
index 63642aa47073a09bef649f6c49b8cd1f5ab11781..f169c8230ac0c7236bf6c170643eeb282b90af25 100644 (file)
@@ -5,3 +5,4 @@ C: -freturn-assignments
 M: 200
 M: '200 200 200'
 M: world
+M: 24