summaryrefslogtreecommitdiff
path: root/lib/coderay/scanners/ruby
diff options
context:
space:
mode:
authormurphy <murphy@rubychan.de>2009-02-06 00:14:10 +0000
committermurphy <murphy@rubychan.de>2009-02-06 00:14:10 +0000
commit30af7bfacf4b1774c4ea9b91652843b2e56ef0cd (patch)
tree2ad3b123520b3fe13e44211fd9c610ac86912918 /lib/coderay/scanners/ruby
parent1ee89811c7bf8fc124e318ca01a605d3dfff1589 (diff)
downloadcoderay-30af7bfacf4b1774c4ea9b91652843b2e56ef0cd.tar.gz
Ruby scanner: Even more fixes for control and meta escape sequences.
* I think I got it right this time.
Diffstat (limited to 'lib/coderay/scanners/ruby')
-rw-r--r--lib/coderay/scanners/ruby/patterns.rb23
1 files changed, 14 insertions, 9 deletions
diff --git a/lib/coderay/scanners/ruby/patterns.rb b/lib/coderay/scanners/ruby/patterns.rb
index 98e4e93..e303894 100644
--- a/lib/coderay/scanners/ruby/patterns.rb
+++ b/lib/coderay/scanners/ruby/patterns.rb
@@ -81,25 +81,30 @@ module Scanners
/ox
METHOD_NAME_OR_SYMBOL = / #{METHOD_NAME_EX} | #{SYMBOL} /ox
- # TODO investigste \M, \c and \C escape sequences
- # (?: M-\\C-|C-\\M-|M-\\c|c\\M-|c|C-|M-)? (?: \\ (?: [0-7]{3} | x[0-9A-Fa-f]{2} | . ) )
- # assert_equal(225, ?\M-a)
- # assert_equal(129, ?\M-\C-a)
- ESCAPE = /
+ SIMPLE_ESCAPE = /
[abefnrstv]
- | (?:M-|C-|c) .?
| [0-7]{1,3}
| x[0-9A-Fa-f]{1,2}
- | .
+ | .?
/mx
-
+
+ CONTROL_META_ESCAPE = /
+ (?: M-|C-|c )
+ (?: \\ (?: M-|C-|c ) )*
+ (?: [^\\] | \\ #{SIMPLE_ESCAPE} )?
+ /mox
+
+ ESCAPE = /
+ #{CONTROL_META_ESCAPE} | #{SIMPLE_ESCAPE}
+ /mox
+
CHARACTER = /
\?
(?:
[^\s\\]
| \\ #{ESCAPE}
)
- /mx
+ /mox
# NOTE: This is not completely correct, but
# nobody needs heredoc delimiters ending with \n.