[vala/wip/gettext: 50/53] vala: Mark special parser errors strings translatable
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/gettext: 50/53] vala: Mark special parser errors strings translatable
- Date: Thu, 20 Sep 2018 11:55:39 +0000 (UTC)
commit 7260bfc035f75ee3f4341a51a6705e6ff9d3353a
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Fri Apr 20 20:51:22 2018 +0200
vala: Mark special parser errors strings translatable
vala/valagenieparser.vala | 44 ++++++++++++++++++-------------------
vala/valaparser.vala | 56 +++++++++++++++++++++++------------------------
2 files changed, 50 insertions(+), 50 deletions(-)
---
diff --git a/vala/valagenieparser.vala b/vala/valagenieparser.vala
index f9534ac99..d3cc77a7b 100644
--- a/vala/valagenieparser.vala
+++ b/vala/valagenieparser.vala
@@ -160,7 +160,7 @@ public class Vala.Genie.Parser : CodeVisitor {
void report_parse_error (ParseError e) {
var begin = get_location ();
next ();
- Report.error (get_src (begin), _("syntax error, ") + e.message);
+ Report.error (get_src (begin), _("syntax error, %s").printf (e.message));
}
inline bool expect (TokenType type) throws ParseError {
@@ -171,7 +171,7 @@ public class Vala.Genie.Parser : CodeVisitor {
TokenType cur = current ();
TokenType pre = tokens[index - 1].type;
- throw new ParseError.SYNTAX ("expected %s but got %s with previous %s", type.to_string (),
cur.to_string (), pre.to_string());
+ throw new ParseError.SYNTAX (_("expected %s but got %s with previous %s"), type.to_string (),
cur.to_string (), pre.to_string());
}
inline bool expect_separator () throws ParseError {
@@ -181,7 +181,7 @@ public class Vala.Genie.Parser : CodeVisitor {
TokenType cur = current ();
- throw new ParseError.SYNTAX ("expected line end or comma but got %s", cur.to_string());
+ throw new ParseError.SYNTAX (_("expected line end or comma but got %s"), cur.to_string());
}
inline bool expect_terminator () throws ParseError {
@@ -191,7 +191,7 @@ public class Vala.Genie.Parser : CodeVisitor {
TokenType cur = current ();
- throw new ParseError.SYNTAX ("expected line end or semicolon but got %s", cur.to_string());
+ throw new ParseError.SYNTAX (_("expected line end or semicolon but got %s"), cur.to_string());
}
inline SourceLocation get_location () {
@@ -340,7 +340,7 @@ public class Vala.Genie.Parser : CodeVisitor {
break;
}
- throw new ParseError.SYNTAX ("expected identifier");
+ throw new ParseError.SYNTAX (_("expected identifier"));
}
string parse_identifier () throws ParseError {
@@ -394,7 +394,7 @@ public class Vala.Genie.Parser : CodeVisitor {
next ();
return new NullLiteral (get_src (begin));
default:
- throw new ParseError.SYNTAX ("expected literal");
+ throw new ParseError.SYNTAX (_("expected literal"));
}
}
@@ -1084,7 +1084,7 @@ public class Vala.Genie.Parser : CodeVisitor {
// array of arrays: new T[][42]
if (size_specified) {
- throw new ParseError.SYNTAX ("size of inner arrays must not be
specified in array creation expression");
+ throw new ParseError.SYNTAX (_("size of inner arrays must not be
specified in array creation expression"));
}
etype = new ArrayType (etype, size_specifier_list.size,
etype.source_reference);
@@ -1182,7 +1182,7 @@ public class Vala.Genie.Parser : CodeVisitor {
var object_creation = expr as ObjectCreationExpression;
if (call == null && object_creation == null) {
Report.error (expr.source_reference, _("syntax error, expected method call"));
- throw new ParseError.SYNTAX ("expected method call");
+ throw new ParseError.SYNTAX (_("expected method call"));
}
if (call != null) {
@@ -1899,7 +1899,7 @@ public class Vala.Genie.Parser : CodeVisitor {
case TokenType.DELETE: return parse_delete_statement ();
case TokenType.VAR:
case TokenType.CONST:
- throw new ParseError.SYNTAX ("embedded statement cannot be declaration ");
+ throw new ParseError.SYNTAX (_("embedded statement cannot be declaration "));
case TokenType.OP_INC:
case TokenType.OP_DEC:
case TokenType.SUPER:
@@ -1912,7 +1912,7 @@ public class Vala.Genie.Parser : CodeVisitor {
if (is_expression ()) {
return parse_expression_statement ();
} else {
- throw new ParseError.SYNTAX ("embedded statement cannot be declaration");
+ throw new ParseError.SYNTAX (_("embedded statement cannot be declaration"));
}
}
}
@@ -2362,10 +2362,10 @@ public class Vala.Genie.Parser : CodeVisitor {
next ();
return "-" + get_last_string ();
default:
- throw new ParseError.SYNTAX ("expected number");
+ throw new ParseError.SYNTAX (_("expected number"));
}
default:
- throw new ParseError.SYNTAX ("expected literal");
+ throw new ParseError.SYNTAX (_("expected literal"));
}
}
@@ -2468,7 +2468,7 @@ public class Vala.Genie.Parser : CodeVisitor {
TokenType cur = current ();
TokenType pre = tokens[index-1].type;
- throw new ParseError.SYNTAX ("expected declaration but got %s with previous %s",
cur.to_string (), pre.to_string());
+ throw new ParseError.SYNTAX (_("expected declaration but got %s with previous %s"),
cur.to_string (), pre.to_string());
}
void parse_declarations (Symbol parent, bool root = false) throws ParseError {
@@ -3011,13 +3011,13 @@ public class Vala.Genie.Parser : CodeVisitor {
if ((method.is_abstract && method.is_virtual)
|| (method.is_abstract && method.overrides)
|| (method.is_virtual && method.overrides)) {
- throw new ParseError.SYNTAX ("only one of `abstract', `virtual', or
`override' may be specified");
+ throw new ParseError.SYNTAX (_("only one of `abstract', `virtual', or
`override' may be specified"));
}
} else {
if (ModifierFlags.ABSTRACT in flags
|| ModifierFlags.VIRTUAL in flags
|| ModifierFlags.OVERRIDE in flags) {
- throw new ParseError.SYNTAX ("the modifiers `abstract', `virtual', and
`override' are not valid for static methods");
+ throw new ParseError.SYNTAX (_("the modifiers `abstract', `virtual', and
`override' are not valid for static methods"));
}
}
@@ -3147,7 +3147,7 @@ public class Vala.Genie.Parser : CodeVisitor {
if (accept (TokenType.GET)) {
if (prop.get_accessor != null) {
- throw new ParseError.SYNTAX ("property get accessor already
defined");
+ throw new ParseError.SYNTAX (_("property get accessor already
defined"));
}
Block block = null;
if (accept_block ()) {
@@ -3161,17 +3161,17 @@ public class Vala.Genie.Parser : CodeVisitor {
bool _construct = false;
if (accept (TokenType.SET)) {
if (readonly) {
- throw new ParseError.SYNTAX ("set block not allowed
for a read only property");
+ throw new ParseError.SYNTAX (_("set block not allowed
for a read only property"));
}
_construct = (context.profile == Profile.GOBJECT) && accept
(TokenType.CONSTRUCT);
} else if (context.profile == Profile.GOBJECT && accept
(TokenType.CONSTRUCT)) {
_construct = true;
} else if (!accept (TokenType.EOL)) {
- throw new ParseError.SYNTAX ("expected get, set, or
construct");
+ throw new ParseError.SYNTAX (_("expected get, set, or
construct"));
}
if (prop.set_accessor != null) {
- throw new ParseError.SYNTAX ("property set accessor already
defined");
+ throw new ParseError.SYNTAX (_("property set accessor already
defined"));
}
Block block = null;
@@ -3249,9 +3249,9 @@ public class Vala.Genie.Parser : CodeVisitor {
}
if (ModifierFlags.STATIC in flags) {
- throw new ParseError.SYNTAX ("`static' modifier not allowed on signals");
+ throw new ParseError.SYNTAX (_("`static' modifier not allowed on signals"));
} else if (ModifierFlags.CLASS in flags) {
- throw new ParseError.SYNTAX ("`class' modifier not allowed on signals");
+ throw new ParseError.SYNTAX (_("`class' modifier not allowed on signals"));
}
set_attributes (sig, attrs);
@@ -3730,7 +3730,7 @@ public class Vala.Genie.Parser : CodeVisitor {
var type_param_list = parse_type_parameter_list ();
if (ModifierFlags.NEW in flags) {
- throw new ParseError.SYNTAX ("`new' modifier not allowed on delegates");
+ throw new ParseError.SYNTAX (_("`new' modifier not allowed on delegates"));
}
var params = new ArrayList<Parameter> ();
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index 8b5a0887b..8cdd29169 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -118,7 +118,7 @@ public class Vala.Parser : CodeVisitor {
void report_parse_error (ParseError e) {
var begin = get_location ();
next ();
- Report.error (get_src (begin), _("syntax error, ") + e.message);
+ Report.error (get_src (begin), _("syntax error, %s").printf (e.message));
}
inline bool expect (TokenType type) throws ParseError {
@@ -126,7 +126,7 @@ public class Vala.Parser : CodeVisitor {
return true;
}
- throw new ParseError.SYNTAX ("expected %s", type.to_string ());
+ throw new ParseError.SYNTAX (_("expected %s"), type.to_string ());
}
inline SourceLocation get_location () {
@@ -263,7 +263,7 @@ public class Vala.Parser : CodeVisitor {
}
break;
default:
- throw new ParseError.SYNTAX ("expected identifier");
+ throw new ParseError.SYNTAX (_("expected identifier"));
}
}
@@ -318,7 +318,7 @@ public class Vala.Parser : CodeVisitor {
next ();
return new NullLiteral (get_src (begin));
default:
- throw new ParseError.SYNTAX ("expected literal");
+ throw new ParseError.SYNTAX (_("expected literal"));
}
}
@@ -885,7 +885,7 @@ public class Vala.Parser : CodeVisitor {
var expr = parse_array_creation_expression ();
return expr;
} else {
- throw new ParseError.SYNTAX ("expected ( or [");
+ throw new ParseError.SYNTAX (_("expected `(' or `['"));
}
}
}
@@ -946,7 +946,7 @@ public class Vala.Parser : CodeVisitor {
// array of arrays: new T[][42]
if (size_specified) {
- throw new ParseError.SYNTAX ("size of inner arrays must not be
specified in array creation expression");
+ throw new ParseError.SYNTAX (_("size of inner arrays must not be
specified in array creation expression"));
}
element_type = new ArrayType (element_type, size_specifier_list.size,
element_type.source_reference);
@@ -1008,7 +1008,7 @@ public class Vala.Parser : CodeVisitor {
var object_creation = expr as ObjectCreationExpression;
if (call == null && object_creation == null) {
Report.error (expr.source_reference, _("syntax error, expected method call"));
- throw new ParseError.SYNTAX ("expected method call");
+ throw new ParseError.SYNTAX (_("expected method call"));
}
if (call != null) {
@@ -1748,7 +1748,7 @@ public class Vala.Parser : CodeVisitor {
case TokenType.DELETE: return parse_delete_statement ();
case TokenType.VAR:
case TokenType.CONST:
- throw new ParseError.SYNTAX ("embedded statement cannot be declaration ");
+ throw new ParseError.SYNTAX (_("embedded statement cannot be declaration "));
case TokenType.OP_INC:
case TokenType.OP_DEC:
case TokenType.BASE:
@@ -1761,7 +1761,7 @@ public class Vala.Parser : CodeVisitor {
if (is_expression ()) {
return parse_expression_statement ();
} else {
- throw new ParseError.SYNTAX ("embedded statement cannot be declaration");
+ throw new ParseError.SYNTAX (_("embedded statement cannot be declaration"));
}
}
}
@@ -2030,7 +2030,7 @@ public class Vala.Parser : CodeVisitor {
type = parse_type (true, true);
if (accept (TokenType.IN)) {
Report.error (type.source_reference, _("syntax error, expected var or type"));
- throw new ParseError.SYNTAX ("expected var or type");
+ throw new ParseError.SYNTAX (_("expected var or type"));
}
}
string id = parse_identifier ();
@@ -2182,10 +2182,10 @@ public class Vala.Parser : CodeVisitor {
next ();
return "-" + get_last_string ();
default:
- throw new ParseError.SYNTAX ("expected number");
+ throw new ParseError.SYNTAX (_("expected number"));
}
default:
- throw new ParseError.SYNTAX ("expected literal");
+ throw new ParseError.SYNTAX (_("expected literal"));
}
}
@@ -2298,10 +2298,10 @@ public class Vala.Parser : CodeVisitor {
// statement
if (attrs != null) {
// no attributes allowed before statements
- throw new ParseError.SYNTAX ("expected statement");
+ throw new ParseError.SYNTAX (_("expected statement"));
}
if (!root) {
- throw new ParseError.SYNTAX ("statements outside blocks allowed only in root
namespace");
+ throw new ParseError.SYNTAX (_("statements outside blocks allowed only in
root namespace"));
}
rollback (begin);
parse_main_block (parent);
@@ -2391,7 +2391,7 @@ public class Vala.Parser : CodeVisitor {
rollback (begin);
- throw new ParseError.SYNTAX ("expected declaration");
+ throw new ParseError.SYNTAX (_("expected declaration"));
}
void parse_declarations (Symbol parent, bool root = false) throws ParseError {
@@ -2732,13 +2732,13 @@ public class Vala.Parser : CodeVisitor {
if ((method.is_abstract && method.is_virtual)
|| (method.is_abstract && method.overrides)
|| (method.is_virtual && method.overrides)) {
- throw new ParseError.SYNTAX ("only one of `abstract', `virtual', or
`override' may be specified");
+ throw new ParseError.SYNTAX (_("only one of `abstract', `virtual', or
`override' may be specified"));
}
} else {
if (ModifierFlags.ABSTRACT in flags
|| ModifierFlags.VIRTUAL in flags
|| ModifierFlags.OVERRIDE in flags) {
- throw new ParseError.SYNTAX ("the modifiers `abstract', `virtual', and
`override' are not valid for %s methods", (ModifierFlags.CLASS in flags) ? "class" : "static");
+ throw new ParseError.SYNTAX (_("the modifiers `abstract', `virtual', and
`override' are not valid for %s methods"), (ModifierFlags.CLASS in flags) ? "class" : "static");
}
}
@@ -2826,7 +2826,7 @@ public class Vala.Parser : CodeVisitor {
if ((prop.is_abstract && prop.is_virtual)
|| (prop.is_abstract && prop.overrides)
|| (prop.is_virtual && prop.overrides)) {
- throw new ParseError.SYNTAX ("only one of `abstract', `virtual', or `override' may be
specified");
+ throw new ParseError.SYNTAX (_("only one of `abstract', `virtual', or `override' may
be specified"));
}
if (accept (TokenType.THROWS)) {
@@ -2839,7 +2839,7 @@ public class Vala.Parser : CodeVisitor {
while (current () != TokenType.CLOSE_BRACE) {
if (accept (TokenType.DEFAULT)) {
if (prop.initializer != null) {
- throw new ParseError.SYNTAX ("property default value already
defined");
+ throw new ParseError.SYNTAX (_("property default value already
defined"));
}
expect (TokenType.ASSIGN);
prop.initializer = parse_expression ();
@@ -2863,7 +2863,7 @@ public class Vala.Parser : CodeVisitor {
if (accept (TokenType.GET)) {
if (prop.get_accessor != null) {
- throw new ParseError.SYNTAX ("property get accessor already
defined");
+ throw new ParseError.SYNTAX (_("property get accessor already
defined"));
}
if (getter_owned) {
@@ -2887,10 +2887,10 @@ public class Vala.Parser : CodeVisitor {
_construct = true;
writable = accept (TokenType.SET);
} else {
- throw new ParseError.SYNTAX ("expected get, set, or
construct");
+ throw new ParseError.SYNTAX (_("expected `get', `set' or
`construct'"));
}
if (prop.set_accessor != null) {
- throw new ParseError.SYNTAX ("property set accessor already
defined");
+ throw new ParseError.SYNTAX (_("property set accessor already
defined"));
}
Block block = null;
if (!accept (TokenType.SEMICOLON)) {
@@ -2919,9 +2919,9 @@ public class Vala.Parser : CodeVisitor {
sig.access = access;
set_attributes (sig, attrs);
if (ModifierFlags.STATIC in flags) {
- throw new ParseError.SYNTAX ("`static' modifier not allowed on signals");
+ throw new ParseError.SYNTAX (_("`static' modifier not allowed on signals"));
} else if (ModifierFlags.CLASS in flags) {
- throw new ParseError.SYNTAX ("`class' modifier not allowed on signals");
+ throw new ParseError.SYNTAX (_("`class' modifier not allowed on signals"));
}
if (ModifierFlags.VIRTUAL in flags) {
sig.is_virtual = true;
@@ -2949,7 +2949,7 @@ public class Vala.Parser : CodeVisitor {
var flags = parse_member_declaration_modifiers ();
expect (TokenType.CONSTRUCT);
if (ModifierFlags.NEW in flags) {
- throw new ParseError.SYNTAX ("`new' modifier not allowed on constructor");
+ throw new ParseError.SYNTAX (_("`new' modifier not allowed on constructor"));
}
var c = new Constructor (get_src (begin));
if (ModifierFlags.STATIC in flags && ModifierFlags.CLASS in flags) {
@@ -2972,7 +2972,7 @@ public class Vala.Parser : CodeVisitor {
expect (TokenType.OPEN_PARENS);
expect (TokenType.CLOSE_PARENS);
if (ModifierFlags.NEW in flags) {
- throw new ParseError.SYNTAX ("`new' modifier not allowed on destructor");
+ throw new ParseError.SYNTAX (_("`new' modifier not allowed on destructor"));
}
var d = new Destructor (get_src (begin));
if (identifier != parent.name) {
@@ -3334,7 +3334,7 @@ public class Vala.Parser : CodeVisitor {
var flags = parse_member_declaration_modifiers ();
var sym = parse_symbol_name ();
if (ModifierFlags.NEW in flags) {
- throw new ParseError.SYNTAX ("`new' modifier not allowed on creation method");
+ throw new ParseError.SYNTAX (_("`new' modifier not allowed on creation method"));
}
CreationMethod method;
if (sym.inner == null) {
@@ -3393,7 +3393,7 @@ public class Vala.Parser : CodeVisitor {
var flags = parse_member_declaration_modifiers ();
expect (TokenType.DELEGATE);
if (ModifierFlags.NEW in flags) {
- throw new ParseError.SYNTAX ("`new' modifier not allowed on delegates");
+ throw new ParseError.SYNTAX (_("`new' modifier not allowed on delegates"));
}
var type = parse_type (true, false);
var sym = parse_symbol_name ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]