aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lexer.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/lexer.py b/lexer.py
index 1f963cc..c4f52d3 100644
--- a/lexer.py
+++ b/lexer.py
@@ -67,9 +67,10 @@ def lex(data):
current += length
# strings
elif char == '"':
- tok, length = get_string(data[current+1:], line)
+ tok, length, offset = get_string(data[current+1:], line)
tokens.append(tok)
current += length
+ line += offset
# bools
elif char == "#":
tok, length = get_bool(data[current+1:], line)
@@ -118,14 +119,17 @@ def get_number(data, line):
def get_string(data, line):
+ offset = 0
counter = 0
string = ""
while data[counter] != '"':
+ if data[counter] == "\n":
+ offset += 1
string += data[counter]
counter += 1
if counter >= len(data):
raise Exception("couldn't parse string")
- return Token(TokenType.STRING, string, string, line), counter + 1
+ return Token(TokenType.STRING, string, string, line), counter + 1, offset
def get_bool(data, line):
if len(data) >= 4 and data[:4] == "true":