From: Wolfgang (Blub) Bumiller Date: Sun, 25 Nov 2012 17:22:00 +0000 (+0100) Subject: Translatable string constants X-Git-Tag: 0.1.9~256 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7838e772dedf0d32b1937adbda1e2515cfabbc4c;p=xonotic%2Fgmqcc.git Translatable string constants --- diff --git a/parser.c b/parser.c index 5d0045d..f669b37 100644 --- a/parser.c +++ b/parser.c @@ -1304,7 +1304,36 @@ static ast_expression* parse_expression_leave(parser_t *parser, bool stopatcomma else 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; if (wantop) {