[vala/0.10: 24/38] Fix error handling for character literals
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.10: 24/38] Fix error handling for character literals
- Date: Sat, 4 Sep 2010 15:03:27 +0000 (UTC)
commit 1a0afab0a32d3626994709c40cc0c176089b5140
Author: Jürg Billeter <j bitron ch>
Date: Fri Aug 20 21:19:10 2010 +0200
Fix error handling for character literals
vala/valacharacterliteral.vala | 2 +-
vala/valascanner.vala | 4 ++++
2 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/vala/valacharacterliteral.vala b/vala/valacharacterliteral.vala
index d368d7d..91a3028 100644
--- a/vala/valacharacterliteral.vala
+++ b/vala/valacharacterliteral.vala
@@ -38,7 +38,7 @@ public class Vala.CharacterLiteral : Literal {
set {
_value = value;
- if (!value.validate () || (value.length != 3 && value.next_char ().get_char () != '\\')) {
+ if (!value.validate ()) {
error = true;
}
}
diff --git a/vala/valascanner.vala b/vala/valascanner.vala
index d5dc063..955b9a0 100644
--- a/vala/valascanner.vala
+++ b/vala/valascanner.vala
@@ -1156,6 +1156,10 @@ public class Vala.Scanner {
Report.error (new SourceReference (source_file, line, column + token_length_in_chars, line, column + token_length_in_chars), "invalid UTF-8 character");
}
}
+ if (current < end && begin[0] == '\'' && current[0] != '\'') {
+ // multiple characters in single character literal
+ Report.error (new SourceReference (source_file, line, column + token_length_in_chars, line, column + token_length_in_chars), "invalid character literal");
+ }
}
if (current < end) {
current++;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]