Sha256: a228e804669463693e2a9951fda40b6e9d0df9bb5a4c9bb7737e6bb8b53fa79a
Contents?: true
Size: 789 Bytes
Versions: 66
Compression:
Stored size: 789 Bytes
Contents
# frozen_string_literal: true require "thread" module Nokogiri module CSS class Parser < Racc::Parser # :nodoc: def initialize @tokenizer = Tokenizer.new super end def parse(string) @tokenizer.scan_setup(string) do_parse end def next_token @tokenizer.next_token end # Get the xpath for +selector+ using +visitor+ def xpath_for(selector, visitor) parse(selector).map do |ast| ast.to_xpath(visitor) end end # On CSS parser error, raise an exception def on_error(error_token_id, error_value, value_stack) after = value_stack.compact.last raise SyntaxError, "unexpected '#{error_value}' after '#{after}'" end end end end
Version data entries
66 entries across 66 versions & 1 rubygems