diff --git a/ExampleCode/strings_across_lines.skiy b/ExampleCode/strings_across_lines.skiy index 63d29b2..b1614fe 100644 --- a/ExampleCode/strings_across_lines.skiy +++ b/ExampleCode/strings_across_lines.skiy @@ -1,4 +1,4 @@ -print("This string +print("This string has been written - across several + across several lines.") diff --git a/PySkiylia/Lexer.py b/PySkiylia/Lexer.py index c195cda..5c2cf22 100644 --- a/PySkiylia/Lexer.py +++ b/PySkiylia/Lexer.py @@ -207,7 +207,7 @@ def findIdentifier(self): #define a way of fetching a string from sourcecode def findString(self): - startIndent = self.char + si = self.char #keep going until we hit the end of the code, or the string terminator while not self.match('"', peek=True): #we support multi-line strings, so if we find a newline, increment the line counter @@ -224,7 +224,9 @@ def findString(self): #fetch the contents of the string, removing the leading and trailing identifiers stringVal = self.source[self.start+1:self.current-1] #remove any whitespace that occured due to newlines - stringVal = " \n".join([x.strip() for x in stringVal.split("\n")]) + if "\n" in stringVal: + sv = stringVal.split("\n") + stringVal = " \n".join([sv[0]]+[x[si:] for x in sv[1:]]) #create the token and return it return self.addToken("String", stringVal)