]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
dova: Do not require @"..." for string templates
authorJürg Billeter <j@bitron.ch>
Wed, 24 Mar 2010 08:08:02 +0000 (09:08 +0100)
committerJürg Billeter <j@bitron.ch>
Wed, 24 Mar 2010 08:22:59 +0000 (09:22 +0100)
Support string interpolation in normal "..." strings.

vala/valacodewriter.vala
vala/valascanner.vala

index a41b388e5be88fbf6893b5058ab3190e8e6fdd2d..04b3d5f1d74e884817394f9f4f11038af4f3f393 100644 (file)
@@ -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);
index d686a49d54fd2ddd8e5b973d15f9e867464e19c2..744dcf14c8ccb37fe6362d298939425ede63cab6 100644 (file)
@@ -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);