diff options
author | murphy <murphy@rubychan.de> | 2008-01-07 14:42:47 +0000 |
---|---|---|
committer | murphy <murphy@rubychan.de> | 2008-01-07 14:42:47 +0000 |
commit | e127b7d57b06554e708752bbbc2a85e833633c26 (patch) | |
tree | ccd44c344594ccacdcd95a1e1dfc35488cb2c58d /lib/coderay/scanners/ruby/patterns.rb | |
parent | bbbbc70a0b2efcd03bbcaf4e08ac139e7969e608 (diff) | |
download | coderay-e127b7d57b06554e708752bbbc2a85e833633c26.tar.gz |
Lib:
- Encoder: removed a warning
- Encoders::HTML: don't shadow outer variable
- Plugin: move require_plugin into class namespace
- Ruby Scanner:
- "alias" keyword recognition
- better regexp/division distinction
- recognize ~, !, !=, and !~ as method names (partly Ruby 1.9 only)
- reordered states for speed
Tests:
- updated coderay-suite to use gem instead of require_gem
- general improvements (more colors!, new parameter: new, new syntax lang.test for only and new)
- fixed ruby suite
- adjusted a lot of Ruby tests (alias uses methods now)
- new tests: ruby/operators, ruby/regexp
Samples:
- fixed/updated ('bout time)
Rake tasks:
- updated to use new rubygems API
Diffstat (limited to 'lib/coderay/scanners/ruby/patterns.rb')
-rw-r--r-- | lib/coderay/scanners/ruby/patterns.rb | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/lib/coderay/scanners/ruby/patterns.rb b/lib/coderay/scanners/ruby/patterns.rb index 39962ec..88fd1e0 100644 --- a/lib/coderay/scanners/ruby/patterns.rb +++ b/lib/coderay/scanners/ruby/patterns.rb @@ -14,19 +14,14 @@ module Scanners DEF_KEYWORDS = %w[ def ] UNDEF_KEYWORDS = %w[ undef ] + ALIAS_KEYWORDS = %w[ alias ] MODULE_KEYWORDS = %w[class module] DEF_NEW_STATE = WordList.new(:initial). add(DEF_KEYWORDS, :def_expected). add(UNDEF_KEYWORDS, :undef_expected). + add(ALIAS_KEYWORDS, :alias_expected). add(MODULE_KEYWORDS, :module_expected) - IDENTS_ALLOWING_REGEXP = %w[ - and or not while until unless if then elsif when sub sub! gsub gsub! - scan slice slice! split - ] - REGEXP_ALLOWED = WordList.new(false). - add(IDENTS_ALLOWING_REGEXP, :set) - PREDEFINED_CONSTANTS = %w[ nil true false self DATA ARGV ARGF __FILE__ __LINE__ @@ -41,12 +36,13 @@ module Scanners METHOD_NAME = / #{IDENT} [?!]? /ox METHOD_NAME_OPERATOR = / \*\*? # multiplication and power - | [-+]@? # plus, minus - | [\/%&|^`~] # division, modulo or format strings, &and, |or, ^xor, `system`, tilde + | [-+~]@? # plus, minus, tilde with and without @ + | [\/%&|^`] # division, modulo or format strings, &and, |or, ^xor, `system` | \[\]=? # array getter and setter | << | >> # append or shift left, shift right | <=?>? | >=? # comparison, rocket operator - | ===? # simple equality and case equality + | ===? | =~ # simple equality, case equality, match + | ![~=@]? # negation with and without @, not-equal and not-match /ox METHOD_NAME_EX = / #{IDENT} (?:[?!]|=(?!>))? | #{METHOD_NAME_OPERATOR} /ox INSTANCE_VARIABLE = / @ #{IDENT} /ox @@ -83,6 +79,7 @@ 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} | . ) ) |