[vala/switch-to-gir] girparser: Default to 'true' when no argument value is provided
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/switch-to-gir] girparser: Default to 'true' when no argument value is provided
- Date: Thu, 26 Aug 2010 20:22:17 +0000 (UTC)
commit 77ee9d43f48ef9ecd89abb8b60d48cdb30fc72c7
Author: Luca Bruno <lethalman88 gmail com>
Date: Thu Aug 26 22:21:36 2010 +0200
girparser: Default to 'true' when no argument value is provided
vala/valagirparser.vala | 24 ++++++++----------------
1 files changed, 8 insertions(+), 16 deletions(-)
---
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index 95a165e..d4b7eee 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -64,16 +64,12 @@ public class Vala.GirParser : CodeVisitor {
class Argument {
public Expression expression;
- public SourceLocation begin;
- public SourceLocation end;
public SourceReference source_reference;
public bool used = false;
- public Argument (Expression expression, SourceLocation begin, SourceLocation end, SourceReference? source_reference = null) {
+ public Argument (Expression expression, SourceReference? source_reference = null) {
this.expression = expression;
- this.begin = begin;
- this.end = end;
this.source_reference = source_reference;
}
}
@@ -359,10 +355,9 @@ public class Vala.GirParser : CodeVisitor {
return metadata;
}
- Expression? parse_literal (out SourceLocation end) {
+ Expression? parse_literal () {
var src = get_current_src ();
Expression expr = null;
-
switch (current) {
case TokenType.TRUE:
expr = new BooleanLiteral (true, src);
@@ -383,13 +378,12 @@ public class Vala.GirParser : CodeVisitor {
Report.error (src, "expected literal");
break;
}
- end = this.end;
next ();
return expr;
}
bool parse_args (Metadata metadata) {
- while (current != TokenType.EOF && !has_newline ()) {
+ while (current != TokenType.EOF && has_space () && !has_newline ()) {
SourceReference src;
var id = parse_identifier (out src, false);
if (id == null) {
@@ -402,18 +396,17 @@ public class Vala.GirParser : CodeVisitor {
}
if (current != TokenType.ASSIGN) {
- Report.error (get_current_src (), "expected `='");
- return false;
+ // threat as `true'
+ metadata.add_argument (arg_type, new Argument (new BooleanLiteral (true, src), src));
+ continue;
}
next ();
- SourceLocation begin = this.begin;
- SourceLocation end;
- Expression expr = parse_literal (out end);
+ Expression expr = parse_literal ();
if (expr == null) {
return false;
}
- metadata.add_argument (arg_type, new Argument (expr, begin, end, src));
+ metadata.add_argument (arg_type, new Argument (expr, src));
}
return true;
@@ -2308,7 +2301,6 @@ public class Vala.GirParser : CodeVisitor {
DataType base_type = null;
Symbol type_sym = null;
if (alias.base_type is UnresolvedType) {
- Symbol parent = alias.parent_namespace;
base_type = alias.base_type;
type_sym = resolve_symbol (alias.parent_namespace.scope, ((UnresolvedType) base_type).unresolved_symbol);
} else if (!(alias.base_type is VoidType)) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]