require 'strscan'
lex = [/"[^\\"]*(?:\\.[^\\"]*)*"/m, # string
/'[^\\']*(?:\\.[^\\']*)*'/m, # char
/\/\*.*?\*\//m, # multi-line
/\/\/(?:.*?\\(?:\r?\n|\r))*.*/, # single-line
/.|\s+/] # rest
ARGV.each do |source|
stream = StringScanner.new File.read source
until stream.eos? do
code = stream.scan lex.find {|regex| stream.match? regex}
print code unless code.start_with?('//') || code.start_with?('/*')
end
end
用户登录
还没有账号?立即注册
用户注册
投稿取消
| 文章分类: |
|
还能输入300字
上传中....
狂欢48863251