lib/kompiler/parsers.rb in kompiler-0.2.0.pre.2 vs lib/kompiler/parsers.rb in kompiler-0.2.0

- old
+ new

@@ -7,10 +7,12 @@ def self.parse_str(code) # Skip the " i = 1 + + quote = code[0] next_char_backslashed = false str_content = "" @@ -18,21 +20,18 @@ if next_char_backslashed if code[i] == "n" str_content << "\n" elsif code[i] == "r" str_content << "\r" - elsif code[i] == "\\" - str_content << "\\" elsif code[i] == "0" str_content << "\0" else - str_content << "\\" str_content << code[i] end next_char_backslashed = false else - if code[i] == "\"" + if code[i] == quote break elsif code[i] == "\\" next_char_backslashed = true else str_content << code[i] @@ -205,11 +204,10 @@ end def self.parse_operand_str(operand_str) - # Check if the operand is a register is_register, register = check_register_operand(operand_str) return {type: "register", value: register, register: register} if is_register # Check if the operand is a string @@ -286,12 +284,12 @@ i += 1 next end # If a string definition, parse to the end of the string - if line[i] == "\"" + if ["\"", "'"].include?(line[i]) str_content, parsed_size = parse_str(line[i..]) - operand_content += '"' + str_content + '"' + operand_content += line[i] + str_content + line[i] i += parsed_size next end # Else just add the character to the operand content \ No newline at end of file