Class: SXP::Reader::Extended

Inherits:
Basic show all
Defined in:
vendor/bundler/ruby/3.3.0/bundler/gems/sxp.rb-7a771a32c5fe/lib/sxp/reader/extended.rb

Overview

An extended S-expression parser.

Direct Known Subclasses

SPARQL, Scheme

Constant Summary collapse

LPARENS =
[?(, ?[]
RPARENS =
[?), ?]]
ATOM =
/^[^\s()\[\]]+/

Constants inherited from Basic

Basic::DECIMAL, Basic::INTEGER, Basic::RATIONAL

Instance Attribute Summary

Attributes inherited from SXP::Reader

#input, #options

Instance Method Summary collapse

Methods inherited from Basic

#read_atom, #read_character, #read_literal, #read_string

Methods inherited from SXP::Reader

#each, #eof?, #initialize, #peek_char, read, #read, read_all, #read_all, #read_atom, #read_char, #read_character, #read_chars, read_file, #read_files, #read_integer, #read_list, #read_literal, #read_sharp, #read_string, read_url, #skip_line, #unread

Constructor Details

This class inherits a constructor from SXP::Reader

Instance Method Details

#read_tokenObject

Returns:



12
13
14
15
16
17
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sxp.rb-7a771a32c5fe/lib/sxp/reader/extended.rb', line 12

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

#skip_comments

This method returns an undefined value.



21
22
23
24
25
26
27
28
29
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sxp.rb-7a771a32c5fe/lib/sxp/reader/extended.rb', line 21

def skip_comments
  until eof?
    case (char = peek_char).chr
      when /\s+/ then skip_char
      when /;/   then skip_line
      else break
    end
  end
end