mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2024-11-24 04:41:25 +00:00
return assignment factorial test
This commit is contained in:
parent
9167de1631
commit
5aba29006b
3 changed files with 15 additions and 1 deletions
5
parser.c
5
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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -5,3 +5,4 @@ C: -freturn-assignments
|
|||
M: 200
|
||||
M: '200 200 200'
|
||||
M: world
|
||||
M: 24
|
||||
|
|
Loading…
Reference in a new issue