mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2024-11-27 22:22:17 +00:00
Translatable string constants
This commit is contained in:
parent
0df394dcbc
commit
7838e772de
1 changed files with 30 additions and 1 deletions
31
parser.c
31
parser.c
|
@ -1304,7 +1304,36 @@ static ast_expression* parse_expression_leave(parser_t *parser, bool stopatcomma
|
||||||
else
|
else
|
||||||
parser->memberof = 0;
|
parser->memberof = 0;
|
||||||
|
|
||||||
if (parser->tok == TOKEN_IDENT)
|
if (parser->tok == TOKEN_IDENT && !strcmp(parser_tokval(parser), "_")) {
|
||||||
|
/* a translatable string */
|
||||||
|
ast_value *val;
|
||||||
|
|
||||||
|
if (wantop) {
|
||||||
|
parseerror(parser, "expected operator or end of statement, got constant");
|
||||||
|
goto onerr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!parser_next(parser) || parser->tok != '(') {
|
||||||
|
parseerror(parser, "use _(\"string\") to create a translatable string constant");
|
||||||
|
goto onerr;
|
||||||
|
}
|
||||||
|
if (!parser_next(parser) || parser->tok != TOKEN_STRINGCONST) {
|
||||||
|
parseerror(parser, "expected a constant string in translatable-string extension");
|
||||||
|
goto onerr;
|
||||||
|
}
|
||||||
|
val = parser_const_string(parser, parser_tokval(parser), true);
|
||||||
|
wantop = true;
|
||||||
|
if (!val)
|
||||||
|
return false;
|
||||||
|
vec_push(sy.out, syexp(parser_ctx(parser), (ast_expression*)val));
|
||||||
|
DEBUGSHUNTDO(con_out("push string\n"));
|
||||||
|
|
||||||
|
if (!parser_next(parser) || parser->tok != ')') {
|
||||||
|
parseerror(parser, "expected closing paren after translatable string");
|
||||||
|
goto onerr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (parser->tok == TOKEN_IDENT)
|
||||||
{
|
{
|
||||||
ast_expression *var;
|
ast_expression *var;
|
||||||
if (wantop) {
|
if (wantop) {
|
||||||
|
|
Loading…
Reference in a new issue