Compare commits

...

3 Commits

Author SHA1 Message Date
Jonathan Tamsut 1b6fc41887 Merge branch 'main' into jtamsut/tokenize-double-quotes 2023-05-01 12:58:18 -07:00
Jonathan Tamsut 9f4cb5f1da run formatter 2023-04-26 18:44:06 -07:00
Jonathan Tamsut fe72328fef token double quotes 2023-04-25 17:38:26 -07:00
+7 -1
View File
@@ -179,6 +179,7 @@ export class Lexer {
break;
case "'":
case '"':
this.consumeString();
break;
@@ -299,8 +300,13 @@ export class Lexer {
}
private consumeString() {
while ((this.peek() !== "'" || this.peekNext() === "'") && !this.atEnd()) {
// TODO: Should I make these consume double quotes as well?
const isSingleQuote = this.peek() !== "'" || this.peekNext() === "'";
const isDoubleQuote = this.peek() !== '"' || this.peekNext() === '"';
while ((isSingleQuote || isDoubleQuote) && !this.atEnd()) {
if (this.peek() === "\n") this.line++;
// TODO: Should I also add this for double quotes?
if (this.peek() === "'" && this.peekNext() === "'") {
// Escaped "'", consume
this.next();