[vala] dova: Do not require @"..." for string templates
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] dova: Do not require @"..." for string templates
- Date: Wed, 24 Mar 2010 08:28:20 +0000 (UTC)
commit 0dae7fe1e749fd24677a3b466d408d4910f40fc7
Author: Jürg Billeter <j bitron ch>
Date: Wed Mar 24 09:08:02 2010 +0100
dova: Do not require @"..." for string templates
Support string interpolation in normal "..." strings.
vala/valacodewriter.vala | 5 +++--
vala/valascanner.vala | 10 +++++++++-
2 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/vala/valacodewriter.vala b/vala/valacodewriter.vala
index a41b388..04b3d5f 100644
--- a/vala/valacodewriter.vala
+++ b/vala/valacodewriter.vala
@@ -1691,8 +1691,9 @@ public class Vala.CodeWriter : CodeVisitor {
private void write_identifier (string s) {
char* id = (char*)s;
int id_length = (int)s.length;
- if ( Vala.Scanner.get_identifier_or_keyword (id, id_length) != Vala.TokenType.IDENTIFIER ||
- s.get_char ().isdigit ()) {
+ if (context.profile != Profile.DOVA &&
+ (Vala.Scanner.get_identifier_or_keyword (id, id_length) != Vala.TokenType.IDENTIFIER ||
+ s.get_char ().isdigit ())) {
stream.putc ('@');
}
write_string (s);
diff --git a/vala/valascanner.vala b/vala/valascanner.vala
index d686a49..744dcf1 100644
--- a/vala/valascanner.vala
+++ b/vala/valascanner.vala
@@ -606,7 +606,7 @@ public class Vala.Scanner {
len++;
}
type = get_identifier_or_keyword (begin, len);
- } else if (current[0] == '@') {
+ } else if (current[0] == '@' && source_file.context.profile != Profile.DOVA) {
if (current < end - 1 && current[1] == '"') {
type = TokenType.OPEN_TEMPLATE;
current += 2;
@@ -913,6 +913,7 @@ public class Vala.Scanner {
case 'n':
case 'r':
case 't':
+ case '$':
current++;
token_length_in_chars++;
break;
@@ -932,6 +933,13 @@ public class Vala.Scanner {
} else if (current[0] == '\n') {
break;
} else {
+ if (type == TokenType.STRING_LITERAL && source_file.context.profile == Profile.DOVA && current[0] == '$') {
+ // string template
+ type = TokenType.OPEN_TEMPLATE;
+ current = begin;
+ state_stack += State.TEMPLATE;
+ break;
+ }
unichar u = ((string) current).get_char_validated ((long) (end - current));
if (u != (unichar) (-1)) {
current += u.to_utf8 (null);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]