Skip to content
Browse files

+ Added --18 and --19 flags to specify parser. Defaults to hybrid.

- Cleaned up some 1.9 warnings.
+ Modified processor to deal with cleaner sexps from RP 3.x.

[git-p4: depot-paths = "//src/flog/dev/": change = 7666]
  • Loading branch information...
1 parent 9671669 commit b1ce79196b581fa71f7a7203df5d5753587fc00c @zenspider zenspider committed Jul 21, 2012
Showing with 15 additions and 4 deletions.
  1. +15 −4 lib/flog.rb
View
19 lib/flog.rb
@@ -133,6 +133,7 @@ def self.parse_options args = ARGV
option = {
:quiet => true,
:continue => false,
+ :parser => RubyParser,
}
OptionParser.new do |opts|
@@ -185,6 +186,14 @@ def self.parse_options args = ARGV
option[:verbose] = true
end
+ opts.on("--18", "Use a ruby 1.8 parser.") do
+ option[:parser] = Ruby18Parser
+ end
+
+ opts.on("--19", "Use a ruby 1.9 parser.") do
+ option[:parser] = Ruby19Parser
+ end
+
next if self.plugins.empty?
opts.separator "Plugin options:"
@@ -251,7 +260,7 @@ def flog(*files_or_dirs)
mass[file] = ast.mass
process ast
rescue RegexpError, SyntaxError, Racc::ParseError => e
- if e.inspect =~ /<%|%>/ or ruby =~ /<%|%>/ then
+ if e.inspect =~ /<\%|%\>/ or ruby =~ /<\%|%\>/ then
warn "#{e.inspect} at #{e.backtrace.first(5).join(', ')}"
warn "\n...stupid lemmings and their bad erb templates... skipping"
else
@@ -308,7 +317,7 @@ def initialize option = {}
@method_stack = []
@method_locations = {}
@mass = {}
- @parser = Ruby18Parser.new
+ @parser = option[:parser].new
self.auto_shift_type = true
self.reset
end
@@ -514,7 +523,7 @@ def process_attrasgn(exp)
add_to_score :assignment
process exp.shift # lhs
exp.shift # name
- process exp.shift # rhs
+ process_until_empty exp # rhs
s()
end
@@ -552,9 +561,11 @@ def process_call(exp)
penalize_by 0.2 do
process exp.shift # recv
end
+
name = exp.shift
+
penalize_by 0.2 do
- process exp.shift # args
+ process_until_empty exp
end
add_to_score name, SCORES[name]

0 comments on commit b1ce791

Please sign in to comment.
Something went wrong with that request. Please try again.