Class: SXP::Reader::Extended

Inherits:
Basic show all
Defined in:
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, #initialize, read, #read, read_all, #read_all, #read_atom, #read_character, read_file, #read_files, #read_integer, #read_list, #read_literal, #read_sharp, #read_string, read_url

Constructor Details

This class inherits a constructor from SXP::Reader

Instance Method Details

#read_tokenObject

Returns:



12
13
14
15
16
17
# File 'lib/sxp/reader/extended.rb', line 12

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

#skip_commentsvoid

This method returns an undefined value.



21
22
23
24
25
26
27
28
29
# File '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