# File lib/parslet/atoms/context.rb, line 19 def cache(obj, source, &block) beg = source.pos # Not in cache yet? Return early. unless entry = lookup(obj, beg) result = yield set obj, beg, [result, source.pos-beg] return result end # the condition in unless has returned true, so entry is not nil. result, advance = entry # The data we're skipping here has been read before. (since it is in # the cache) PLUS the actual contents are not interesting anymore since # we know obj matches at beg. So skip reading. source.pos = beg + advance return result end