1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
hack for speed


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1019 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
shugo 2000-10-27 07:20:02 +00:00
parent cac38b30e5
commit 24053a65d0

View file

@ -1500,8 +1500,23 @@ module Net
end
end
ADDRESS_REGEXP = /\G\
(?# 1: NAME )(?:NIL|"((?:[^\x80-\xff\x00\r\n"\\]|\\["\\])*)") \
(?# 2: ROUTE )(?:NIL|"((?:[^\x80-\xff\x00\r\n"\\]|\\["\\])*)") \
(?# 3: MAILBOX )(?:NIL|"((?:[^\x80-\xff\x00\r\n"\\]|\\["\\])*)") \
(?# 4: HOST )(?:NIL|"((?:[^\x80-\xff\x00\r\n"\\]|\\["\\])*)")\
\)/ni
def address
match(T_LPAR)
if @str.index(ADDRESS_REGEXP, @pos)
# address does not include literal.
@pos = $~.end(0)
name = $1 ? $1.gsub(/\\(["\\])/n, "\\1") : nil
route = $2 ? $2.gsub(/\\(["\\])/n, "\\1") : nil
mailbox = $3 ? $3.gsub(/\\(["\\])/n, "\\1") : nil
host = $4 ? $4.gsub(/\\(["\\])/n, "\\1") : nil
else
name = nstring
match(T_SPACE)
route = nstring
@ -1510,39 +1525,55 @@ module Net
match(T_SPACE)
host = nstring
match(T_RPAR)
end
return Address.new(name, route, mailbox, host)
end
def flag_list
result = []
match(T_LPAR)
while true
token = lookahead
case token.symbol
when T_RPAR
shift_token
break
when T_SPACE
shift_token
end
result.push(flag)
end
return result
end
# def flag_list
# result = []
# match(T_LPAR)
# while true
# token = lookahead
# case token.symbol
# when T_RPAR
# shift_token
# break
# when T_SPACE
# shift_token
# end
# result.push(flag)
# end
# return result
# end
def flag
token = lookahead
if token.symbol == T_BSLASH
shift_token
token = lookahead
if token.symbol == T_STAR
shift_token
return token.value.intern
# def flag
# token = lookahead
# if token.symbol == T_BSLASH
# shift_token
# token = lookahead
# if token.symbol == T_STAR
# shift_token
# return token.value.intern
# else
# return atom.intern
# end
# else
# return atom
# end
# end
FLAG_REGEXP = /\
(?# FLAG )\\([^\x80-\xff(){ \x00-\x1f\x7f%"\\]+)|\
(?# ATOM )([^\x80-\xff(){ \x00-\x1f\x7f%*"\\]+)/n
def flag_list
if @str.index(/\(([^)]*)\)/ni, @pos)
@pos = $~.end(0)
return $1.scan(FLAG_REGEXP).collect { |flag, atom|
atom || flag.intern
}
else
return atom.intern
end
else
return atom
parse_error("invalid flag list")
end
end