summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--etc/coderay-lib.tmproj16
-rw-r--r--etc/simple_regexp_scanner.rb11
-rw-r--r--lib/coderay/scanners/java_script.rb1
-rw-r--r--lib/coderay/scanners/ruby/patterns.rb2
-rw-r--r--test/scanners/ruby/regexp.expected.raydebug15
-rw-r--r--test/scanners/ruby/regexp.in.rb15
6 files changed, 46 insertions, 14 deletions
diff --git a/etc/coderay-lib.tmproj b/etc/coderay-lib.tmproj
index fc48f5c..858d7bc 100644
--- a/etc/coderay-lib.tmproj
+++ b/etc/coderay-lib.tmproj
@@ -15,8 +15,6 @@
<string>../lib</string>
</dict>
<dict>
- <key>expanded</key>
- <true/>
<key>name</key>
<string>bin</string>
<key>regexFolderFilter</key>
@@ -33,8 +31,6 @@
<string>../ftp.yaml</string>
</dict>
<dict>
- <key>expanded</key>
- <true/>
<key>name</key>
<string>etc</string>
<key>regexFolderFilter</key>
@@ -67,8 +63,6 @@
<string>../pkg</string>
</dict>
<dict>
- <key>expanded</key>
- <true/>
<key>name</key>
<string>rake_helpers</string>
<key>regexFolderFilter</key>
@@ -77,8 +71,6 @@
<string>../rake_helpers</string>
</dict>
<dict>
- <key>expanded</key>
- <true/>
<key>name</key>
<string>rake_tasks</string>
<key>regexFolderFilter</key>
@@ -90,13 +82,15 @@
<key>filename</key>
<string>../Rakefile</string>
<key>lastUsed</key>
- <date>2009-01-13T15:38:32Z</date>
+ <date>2009-01-22T14:33:27Z</date>
</dict>
<dict>
<key>filename</key>
<string>../diff</string>
<key>lastUsed</key>
- <date>2009-01-13T16:07:48Z</date>
+ <date>2009-02-02T10:25:08Z</date>
+ <key>selected</key>
+ <true/>
</dict>
<dict>
<key>filename</key>
@@ -116,7 +110,7 @@
<key>filename</key>
<string>../test/scanners/coderay_suite.rb</string>
<key>lastUsed</key>
- <date>2009-01-13T15:34:57Z</date>
+ <date>2009-01-22T13:52:45Z</date>
</dict>
<dict>
<key>filename</key>
diff --git a/etc/simple_regexp_scanner.rb b/etc/simple_regexp_scanner.rb
index 6e1d098..e89460e 100644
--- a/etc/simple_regexp_scanner.rb
+++ b/etc/simple_regexp_scanner.rb
@@ -91,6 +91,17 @@ class SimpleRegexpScannerTest < Test::Unit::TestCase
assert_scans_list '(A(B(C|D))?)?', ['ABC', 'ABD', 'A', '']
end
+ def test_deep_recusion
+ n = 1_000
+ assert_nothing_raised do
+ assert_scans_list '(' * n + ')' * n, ['']
+ end
+ n = 10_000
+ assert_raise SystemStackError do
+ assert_scans_list '(' * n + ')' * n, ['']
+ end
+ end
+
JAVA_BUILTIN_TYPES = <<-TYPES.delete(" \n")
(R(GBImageFilter|MI(S(ocketFactory|e(curity(Manager|Exception)|rver(SocketFactor
y|Impl(_Stub)?)?))|C(onnect(ion(Impl(_Stub)?)?|or(Server)?)|l(ientSocketFactory|
diff --git a/lib/coderay/scanners/java_script.rb b/lib/coderay/scanners/java_script.rb
index 0187e5b..e9ae14f 100644
--- a/lib/coderay/scanners/java_script.rb
+++ b/lib/coderay/scanners/java_script.rb
@@ -104,6 +104,7 @@ module Scanners
# TODO: string key recognition
# There's a problem with expressions like: PAIRS: { 'slide': ['SlideDown','SlideUp'], ... }.
+ # The commas in the array are confusing the scanner here.
# elsif key_expected && match = scan(/["']/)
# tokens << [:open, :key]
# state = :key
diff --git a/lib/coderay/scanners/ruby/patterns.rb b/lib/coderay/scanners/ruby/patterns.rb
index c18789b..98e4e93 100644
--- a/lib/coderay/scanners/ruby/patterns.rb
+++ b/lib/coderay/scanners/ruby/patterns.rb
@@ -87,7 +87,7 @@ module Scanners
# assert_equal(129, ?\M-\C-a)
ESCAPE = /
[abefnrstv]
- | M-\\C-|C-\\M-|M-\\c|c\\M-|c|C-|M-
+ | (?:M-|C-|c) .?
| [0-7]{1,3}
| x[0-9A-Fa-f]{1,2}
| .
diff --git a/test/scanners/ruby/regexp.expected.raydebug b/test/scanners/ruby/regexp.expected.raydebug
index 43f1d91..4d6086b 100644
--- a/test/scanners/ruby/regexp.expected.raydebug
+++ b/test/scanners/ruby/regexp.expected.raydebug
@@ -2,4 +2,17 @@ comment(# Regexp or division?)
ident(some_string)operator(.)ident(to_i) regexp<delimiter(/)char(\\s)content(+)delimiter(/)>
ident(some_string)operator(.)ident(split) operator(/) operator(+)regexp<delimiter(/)content( this is a regexp after a division )delimiter(/)>
ident(some_string)operator(.)ident(split) operator(/) operator(+) regexp<delimiter(/)content( this one, too )delimiter(/)>
-ident(some_string)operator(.)ident(split) regexp<delimiter(/)content(- )delimiter(/)> comment(# and this one is a regexp without division) \ No newline at end of file
+ident(some_string)operator(.)ident(split) regexp<delimiter(/)content(- )delimiter(/)> comment(# and this one is a regexp without division)
+
+ident(it) string<delimiter(")content(allows substitution to interact with other Regexp constructs)delimiter(")> reserved(do)
+ ident(str) operator(=) string<delimiter(")content(foo\)|(bar)delimiter(")>
+ regexp<delimiter(/)content(()inline<inline_delimiter(#{)ident(str)inline_delimiter(})>content(\))delimiter(/)>operator(.)ident(should) operator(==) regexp<delimiter(/)content((foo\)|(bar\))delimiter(/)>
+
+ ident(str) operator(=) string<delimiter(")content(a)delimiter(")>
+ regexp<delimiter(/)content([)inline<inline_delimiter(#{)ident(str)inline_delimiter(})>content(-z])delimiter(/)>operator(.)ident(should) operator(==) regexp<delimiter(/)content([a-z])delimiter(/)>
+
+ ident(not_compliant_on)operator(()symbol(:ruby)operator(\)) reserved(do)
+ ident(str) operator(=) string<delimiter(")content(J)delimiter(")>
+ ident(re) operator(=) regexp<delimiter(/)char(\\c#)content({str})delimiter(/)>operator(.)ident(should) operator(==) regexp<delimiter(/)char(\\cJ)delimiter(/)>
+ reserved(end)
+reserved(end) \ No newline at end of file
diff --git a/test/scanners/ruby/regexp.in.rb b/test/scanners/ruby/regexp.in.rb
index 956e6b8..e10e7a8 100644
--- a/test/scanners/ruby/regexp.in.rb
+++ b/test/scanners/ruby/regexp.in.rb
@@ -2,4 +2,17 @@
some_string.to_i /\s+/
some_string.split / +/ this is a regexp after a division /
some_string.split / + / this one, too /
-some_string.split /- / # and this one is a regexp without division \ No newline at end of file
+some_string.split /- / # and this one is a regexp without division
+
+it "allows substitution to interact with other Regexp constructs" do
+ str = "foo)|(bar"
+ /(#{str})/.should == /(foo)|(bar)/
+
+ str = "a"
+ /[#{str}-z]/.should == /[a-z]/
+
+ not_compliant_on(:ruby) do
+ str = "J"
+ re = /\c#{str}/.should == /\cJ/
+ end
+end \ No newline at end of file