H.Yamamoto
2/27/2006 8:04:00 AM
Hello.
It seems that rdoc should not treat \ as escape character
inside regurar expression and single quoted string.
Does this work?
# I haven't read all rdoc parser's code, so this is just hack.
# I'll test this on `make install-doc` later.
Index: parse_rb.rb
===================================================================
RCS file: /src/ruby/lib/rdoc/parsers/parse_rb.rb,v
retrieving revision 1.41
diff -u -w -b -p -r1.41 parse_rb.rb
--- parse_rb.rb 18 Feb 2006 15:35:32 -0000 1.41
+++ parse_rb.rb 27 Feb 2006 07:53:07 -0000
@@ -560,7 +560,7 @@ class RubyLex
"q" => "\'",
"Q" => "\"",
"x" => "\`",
- "r" => "\/",
+ "r" => "/",
"w" => "]"
}
@@ -575,7 +575,7 @@ class RubyLex
"\'" => TkSTRING,
"\"" => TkSTRING,
"\`" => TkXSTRING,
- "\/" => TkREGEXP,
+ "/" => TkREGEXP,
"]" => TkDSTRING
}
Ltype2Token.default = TkSTRING
@@ -583,7 +583,7 @@ class RubyLex
DLtype2Token = {
"\"" => TkDSTRING,
"\`" => TkDXSTRING,
- "\/" => TkDREGEXP,
+ "/" => TkDREGEXP,
}
def lex_init()
@@ -1230,7 +1230,7 @@ class RubyLex
else
ungetc(ch)
end
- elsif ch == '\\' #'
+ elsif @ltype != "'" && @ltype != "/" and ch == '\\' #'
str << read_escape
end
end
///////////////////////////////////////////
class A
def foo
end
def bar
end
end
class B
def baz
# Probably this is fixed
# /\^/
# Probably this is fixed
# %r{\^}
# Is this valid string?
# "\^"
# Probably this is fixed
# '\^'
end
def foz
end
end
class C
def boo
end
def far
end
end