vala r1403 - in trunk: . vala
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r1403 - in trunk: . vala
- Date: Tue, 20 May 2008 21:27:06 +0000 (UTC)
Author: juergbi
Date: Tue May 20 21:27:06 2008
New Revision: 1403
URL: http://svn.gnome.org/viewvc/vala?rev=1403&view=rev
Log:
2008-05-20 Juerg Billeter <j bitron ch>
* vala/valaparser.vala:
* vala/valascanner.vala:
* vala/valatokentype.vala:
Add support for """verbatim strings"""
Modified:
trunk/ChangeLog
trunk/vala/valaparser.vala
trunk/vala/valascanner.vala
trunk/vala/valatokentype.vala
Modified: trunk/vala/valaparser.vala
==============================================================================
--- trunk/vala/valaparser.vala (original)
+++ trunk/vala/valaparser.vala Tue May 20 21:27:06 2008
@@ -265,6 +265,11 @@
case TokenType.STRING_LITERAL:
next ();
return new StringLiteral (get_last_string (), get_src (begin));
+ case TokenType.VERBATIM_STRING_LITERAL:
+ next ();
+ string raw_string = get_last_string ();
+ string escaped_string = raw_string.substring (3, raw_string.len () - 6).escape ("");
+ return new StringLiteral ("\"%s\"".printf (escaped_string), get_src (begin));
case TokenType.NULL:
next ();
return new NullLiteral (get_src (begin));
@@ -426,6 +431,7 @@
case TokenType.REAL_LITERAL:
case TokenType.CHARACTER_LITERAL:
case TokenType.STRING_LITERAL:
+ case TokenType.VERBATIM_STRING_LITERAL:
case TokenType.NULL:
expr = parse_literal ();
break;
@@ -779,6 +785,7 @@
case TokenType.REAL_LITERAL:
case TokenType.CHARACTER_LITERAL:
case TokenType.STRING_LITERAL:
+ case TokenType.VERBATIM_STRING_LITERAL:
case TokenType.NULL:
case TokenType.THIS:
case TokenType.BASE:
Modified: trunk/vala/valascanner.vala
==============================================================================
--- trunk/vala/valascanner.vala (original)
+++ trunk/vala/valascanner.vala Tue May 20 21:27:06 2008
@@ -610,6 +610,28 @@
case '"':
if (begin[0] == '\'') {
type = TokenType.CHARACTER_LITERAL;
+ } else if (current < end - 6 && begin[1] == '"' && begin[2] == '"') {
+ type = TokenType.VERBATIM_STRING_LITERAL;
+ token_length_in_chars = 6;
+ current += 3;
+ while (current < end - 4) {
+ if (current[0] == '"' && current[1] == '"' && current[2] == '"') {
+ break;
+ }
+ unichar u = ((string) current).get_char_validated ((long) (end - current));
+ if (u != (unichar) (-1)) {
+ current += u.to_utf8 (null);
+ token_length_in_chars++;
+ } else {
+ Report.error (new SourceReference (source_file, line, column + token_length_in_chars, line, column + token_length_in_chars), "invalid UTF-8 character");
+ }
+ }
+ if (current[0] == '"' && current[1] == '"' && current[2] == '"') {
+ current += 3;
+ } else {
+ Report.error (new SourceReference (source_file, line, column + token_length_in_chars, line, column + token_length_in_chars), "syntax error, expected \"\"\"");
+ }
+ break;
} else {
type = TokenType.STRING_LITERAL;
}
Modified: trunk/vala/valatokentype.vala
==============================================================================
--- trunk/vala/valatokentype.vala (original)
+++ trunk/vala/valatokentype.vala Tue May 20 21:27:06 2008
@@ -132,6 +132,7 @@
TYPEOF,
USING,
VAR,
+ VERBATIM_STRING_LITERAL,
VIRTUAL,
VOID,
VOLATILE,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]