@@ -39,11 +39,14 @@ def tokenize(self):
39
39
if self .current_character in Dictionary .NUMERIC_CHARACTERS :
40
40
tokens .append (self .digit_tokenize ())
41
41
# Arithmetic operators (single symbols)
42
- elif self .current_character in Dictionary .operators :
43
- tokens .append (Dictionary .operators [self .current_character ])
42
+ elif self .current_character in Dictionary .arithmetic_operators :
43
+ tokens .append (Dictionary .arithmetic_operators [self .current_character ])
44
44
# Keywords, identifiers and multi-word arithmetic operators
45
45
elif self .current_character in Dictionary .ALPHABETIC_CHARACTERS :
46
46
tokens .append (self .keyword_tokenize ())
47
+ # Strings
48
+ elif self .current_character == "\" " or self .current_character == "\' " :
49
+ tokens .append (self .string_tokenize ())
47
50
# White spaces and escape characters
48
51
elif self .current_character in Dictionary .escape_characters :
49
52
tokens .append (self .escape_tokenize ())
@@ -180,4 +183,19 @@ def handle_excel_cell(self):
180
183
181
184
# Tokenize white spaces and escape characters (newline and tab)
182
185
def escape_tokenize (self ):
183
- return Dictionary .escape_characters .get (self .current_character )
186
+ return Dictionary .escape_characters .get (self .current_character )
187
+
188
+ # Generate string token (e.g. STR:'Hasta la vista, baby.' or STR:"Say hello to my little friend!")
189
+ def string_tokenize (self ):
190
+ string = ""
191
+ quote_type = self .current_character # Single or double quote
192
+ self .next_character ()
193
+
194
+ while (self .current_character is not None ) and (self .current_character != quote_type ):
195
+ string += self .current_character
196
+ self .next_character ()
197
+
198
+ # Add opening and closing quotes to string
199
+ string = quote_type + string + quote_type
200
+
201
+ return Token (Dictionary .STRING , string )
0 commit comments