Sha256: f34071d0d84ce6ba49886630e553af305a8a51ddab971a24cfcf0be5775d29ae
Contents?: true
Size: 948 Bytes
Versions: 19
Compression:
Stored size: 948 Bytes
Contents
# encoding: UTF-8 # Copyright 2012 Twitter, Inc # http://www.apache.org/licenses/LICENSE-2.0 module TwitterCldr module Parsers class UnexpectedTokenError < StandardError; end # base class, not meant to be instantiated class Parser def parse(tokens, options = {}) @tokens = tokens reset do_parse(options) end def reset @token_index = 0 end private def next_token(type) unless current_token.type == type raise UnexpectedTokenError.new("Unexpected token #{current_token.type} \"#{current_token.value}\"") end @token_index += 1 while current_token && empty?(current_token) @token_index += 1 end current_token end def empty?(token) token.type == :plaintext && token.value == "" end def current_token @tokens[@token_index] end end end end
Version data entries
19 entries across 19 versions & 2 rubygems