Sha256: c11d89f5df8ecf80ac0b224054794f4a38fffd2985b83fc31bf7961cc3eaf052

Contents?: true

Size: 623 Bytes

Versions: 2

Compression:

Stored size: 623 Bytes

Contents

module SXP; class Reader
  ##
  # An extended S-expression parser.
  class Extended < Basic
    LPARENS  = [?(, ?[].freeze
    RPARENS  = [?), ?]].freeze
    ATOM     = /^[^\s()\[\]]+/.freeze

    ##
    # @return [Object]
    def read_token
      case peek_char
        when ?[, ?] then [:list, read_char]
        else super
      end
    end

    ##
    # @return [void]
    def skip_comments
      until eof?
        case (char = peek_char).chr
          when /\s+/ then skip_char
          when /;/   then skip_line
          else break
        end
      end
    end
  end # class Extended
end; end # class SXP::Reader

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sxp-0.0.7 lib/sxp/reader/extended.rb
sxp-0.0.6 lib/sxp/reader/extended.rb