lib/textbringer/modes/ruby_mode.rb in textbringer-0.1.8 vs lib/textbringer/modes/ruby_mode.rb in textbringer-0.1.9
- old
+ new
@@ -25,17 +25,28 @@
super | self | nil | true | false | and | or | not | alias
) \b | defined\? )
/x
define_syntax :string, /
- (?: (?<! [a-zA-Z] ) \? (:? [^\\\s] | \\ . ) ) |
- (?: %[qQrwWsix]?\{ (?: [^\\}] | \\ . )* \} ) |
- (?: %[qQrwWsix]?\( (?: [^\\)] | \\ . )* \) ) |
- (?: %[qQrwWsix]?\[ (?: [^\\\]] | \\ . )* \] ) |
- (?: %[qQrwWsix]?< (?: [^\\>] | \\ . )* > ) |
+ (?: (?<! [a-zA-Z] ) \?
+ (:?
+ [^\\\s] |
+ \\ [0-7]{1,3} |
+ \\x [0-9a-fA-F]{2} |
+ \\u [0-9a-fA-F]{4} |
+ \\u \{ [0-9a-fA-F]+ \} |
+ \\C - . |
+ \\M - . |
+ \\ .
+ )
+ ) |
+ (?: %[qQrwWsiIx]?\{ (?: [^\\}] | \\ . )* \} ) |
+ (?: %[qQrwWsiIx]?\( (?: [^\\)] | \\ . )* \) ) |
+ (?: %[qQrwWsiIx]?\[ (?: [^\\\]] | \\ . )* \] ) |
+ (?: %[qQrwWsiIx]?< (?: [^\\>] | \\ . )* > ) |
(?:
- %[qQrwWsix]?
+ %[qQrwWsiIx]?
(?<string_delimiter>[^{(\[<a-zA-Z0-9\s\u{0100}-\u{10ffff}])
(?: (?! \k<string_delimiter> ) [^\\] | \\ . )*
\k<string_delimiter>
) |
(?:
@@ -59,17 +70,22 @@
) \s*
\/ (?: [^\\\/] | \\ . )* \/[iomxneus]*
) |
(?:
(?<! class | class \s | [\]})"'.] | :: | \w )
- <<-?(?<heredoc_quote>['"`]?)
+ <<[\-~]?(?<heredoc_quote>['"`]?)
(?<heredoc_terminator>
- [_a-zA-Z\u{0100}-\u{10ffff}]
- [_a-zA-Z0-9\u{0100}-\u{10ffff}]*
+ (?> [_a-zA-Z\u{0100}-\u{10ffff}]
+ [_a-zA-Z0-9\u{0100}-\u{10ffff}]* )
)
\k<heredoc_quote>
- (?> (?:.|\n)*? \k<heredoc_terminator> )
+ (?> (?:.|\n)*? ^ [\ \t]* \k<heredoc_terminator> $ )
+ ) |
+ (?:
+ (?<! : ) :
+ [_a-zA-Z\u{0100}-\u{10ffff}]
+ [_a-zA-Z0-9\u{0100}-\u{10ffff}]*
)
/x
def initialize(buffer)
super(buffer)
@@ -254,9 +270,11 @@
stack = []
(tokens.size - 1).downto(0) do |i|
(line, column), event, text = tokens[i]
case event
when :on_kw
+ _, prev_event, _ = tokens[i - 1]
+ next if prev_event == :on_symbeg
case text
when "class", "module", "def", "if", "unless", "case",
"do", "for", "while", "until", "begin"
if /\A(if|unless|while|until)\z/ =~ text
ts = tokens[0...i].reverse_each.take_while { |(l,_),| l == line }