Closed hikari-no-yume closed 10 years ago
Well it was a grammar thing I think, I just decided to support double quoted strings first, as they seem to be the the way most languages define strings. Single quote strings are somehow "optional" although I do prefer them over double quotes, if you want to try it support for single quoted strings could be added just by updating the grammar.
string
= '"' '"' _ { return { type: 'STRING', value: "" }; }
/ '"' chars:chars '"' _* { return { type: 'STRING', value: chars }; }
chars
= chars:char+ { return chars.join(""); }
char
// any-Unicode-character-except-"-or-\-or-control-character
= [^"\\\0-\x1F\x7f]
/ '\\"' { return '"'; }
/ "\\\\" { return "\\"; }
/ "\\/" { return "/"; }
/ "\\b" { return "\b"; }
/ "\\f" { return "\f"; }
/ "\\n" { return "\n"; }
/ "\n" { return "\n"; }
/ "\\r" { return "\r"; }
/ "\\t" { return "\t"; }
That's how strings are defined now.
Ah, I see. For the time being I'll close this, I'm not sure it really needs single-quoted strings.
What's the future of them, and what is the past? It would appear you used to support single-quoted strings, but then got rid of them.
Personally, I like single-quoted strings as I don't need to press the SHIFT key to type them, while I do for double-quoted strings. But then, for a lot of the places where I might use a single-quoted string, I could just use a symbol like
:foo
.Is the decision just to stick with double-quoted strings?