Skip to content

Commit

Permalink
Implement Any in Evaluator.
Browse files Browse the repository at this point in the history
  • Loading branch information
brixen committed Oct 24, 2010
1 parent d9c1a8c commit f51a5c8
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lib/pegarus/evaluator.rb
Expand Up @@ -15,12 +15,32 @@ def match(subject)
end

def match(pattern, subject)
@subject = subject
@failure = false
@index = 0

pattern.visit self

failure? ? nil : @index
end

def failure
@failure = true
end

def failure?
@failure
end

def always(pattern)
end

def any(pattern)
if @subject.size > @index + pattern.count
@index += pattern.count
else
failure
end
end

def any_range(pattern)
Expand Down

0 comments on commit f51a5c8

Please sign in to comment.