Permalink
Browse files

notional but not working proc behavior

  • Loading branch information...
1 parent dbfb3d1 commit 34c20bf7b5adbcfddf3a67cbdeccd954fb35b16e bglusman committed Jan 27, 2012
Showing with 9 additions and 4 deletions.
  1. +9 −4 lib/outlaw/rule.rb
View
@@ -17,14 +17,19 @@ class << self
def test(program, start_index, pattern)
pattern_index = 0
params = params_count_hash(pattern)
- start_index.upto(program.length) do |index|
- code = program[index]
- part = pattern[pattern_index]
-
+ pattern_proc = proc {|index|
next if IGNORE_TYPES.include? token_type(code)
return false unless match_token?(code, part, params[part])
pattern_index +=1
return true if pattern_index >= pattern.length
+ }
+ default_proc = proc {|block| block.call }
+ start_index.upto(program.length) do |index|
+ code = program[index]
+ part = pattern[pattern_index]
+
+ part.kind_of?(Proc) ? (part.call(pattern_proc)) : (default_proc.call(pattern_proc))
+
end
return false

0 comments on commit 34c20bf

Please sign in to comment.