lib/textbringer/modes/c_mode.rb in textbringer-0.2.1 vs lib/textbringer/modes/c_mode.rb in textbringer-0.2.2

- old
+ new

@@ -76,12 +76,12 @@ (?<comment> (?<multiline_comment> \/\* (?> (?:.|\n)*? \*\/ ) ) | (?<singleline_comment> \/\/ .*(?:\\\n.*)*(?<!\\)\n ) ) | (?<partial_comment> - (?<multiline_comment> \/\* (?:.|\n)* ) | - (?<singleline_comment> \/\/ .*? \\\n (?:.|\n)* ) + (?<partial_multiline_comment> \/\* (?:.|\n)* ) | + (?<partial_singleline_comment> \/\/ .*? \\\n (?:.|\n)* ) ) | (?<keyword> (?: #{KEYWORDS.join("|")} ) \b ) | (?<constant> @@ -175,14 +175,13 @@ (?<unknown>.) )/x def lex(s) tokens = [] - pos = 0 line = 1 column = 0 - while pos < s.size && s.index(TOKEN_REGEXP, pos) + s.scan(TOKEN_REGEXP) do text = $& token_name = TOKEN_NAMES.find { |name| $~[name] } if text.empty? raise EditorError, "Empty token: (#{line},#{column}) #{$~.inspect}" end @@ -192,10 +191,9 @@ line += lf_count column = text.slice(/[^\n]*\z/).size else column += text.size end - pos += text.size end tokens end private