Sha256: bb3d17d45468896aaef7e4a01c6d025ff15a701e6b25751d7e1cbf721aea7873
Contents?: true
Size: 612 Bytes
Versions: 76
Compression:
Stored size: 612 Bytes
Contents
# frozen_string_literal: true require 'ripper' module Hamlit class RubyExpression < Ripper class ParseError < StandardError; end def self.syntax_error?(code) self.new(code).parse false rescue ParseError true end def self.string_literal?(code) return false if syntax_error?(code) type, instructions = Ripper.sexp(code) return false if type != :program return false if instructions.size > 1 type, _ = instructions.first type == :string_literal end private def on_parse_error(*) raise ParseError end end end
Version data entries
76 entries across 76 versions & 1 rubygems