summaryrefslogtreecommitdiff
path: root/src/parsetree.cc
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2014-01-14 20:16:55 -0500
committerAdrian Thurston <thurston@complang.org>2014-01-14 20:16:55 -0500
commit719bedbccdf190d173c2078415c29553c6beecb3 (patch)
treed8888c385801d8868f145116e407da64ee9ab91e /src/parsetree.cc
parentaa51dab49b282283a7e7b45ea65221f3eb87b8c0 (diff)
downloadcolm-719bedbccdf190d173c2078415c29553c6beecb3.tar.gz
added backtick lexical syntax for literal tokens
Added a new syntax for literal tokens. A single backtick is starts the literal. Ends at whitespace or ] in second or greater position. The zero length token is now just a plain backtick. Removed comma as separator in literal statement. Single-quoted strings are now treated like double-quoted strings. They may appear in expressions and are concatenated with the other string forms. Allowing ',' in parameter and argument lists to separate arguments, eg foo('a', 'b').
Diffstat (limited to 'src/parsetree.cc')
-rw-r--r--src/parsetree.cc29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/parsetree.cc b/src/parsetree.cc
index 08cf0dec..cb522063 100644
--- a/src/parsetree.cc
+++ b/src/parsetree.cc
@@ -49,20 +49,27 @@ void prepareLitString( String &result, bool &caseInsensitive,
caseInsensitive = false;
char *src = srcString.data + 1;
- char *end = srcString.data + srcString.length() - 1;
+ char *end = 0;
- while ( *end != '\'' && *end != '\"' && *end != '\n' ) {
- if ( *end == 'i' )
- caseInsensitive = true;
- else {
- error( loc ) << "literal string '" << *end <<
- "' option not supported" << endl;
+ if ( srcString.data[0] != '`' ) {
+ end = srcString.data + srcString.length() - 1;
+
+ while ( *end != '\'' && *end != '\"' && *end != '`' && *end != '\n' ) {
+ if ( *end == 'i' )
+ caseInsensitive = true;
+ else {
+ error( loc ) << "literal string '" << *end <<
+ "' option not supported" << endl;
+ }
+ end -= 1;
}
- end -= 1;
- }
- if ( *end == '\n' )
- end++;
+ if ( *end == '\n' )
+ end++;
+ }
+ else {
+ end = srcString.data + srcString.length();
+ }
char *dest = result.data;
int len = 0;