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

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

Constants inherited from Basic

ATOM, DECIMAL, INTEGER, LPARENS, RATIONAL, RPARENS

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

Constructor Details

This class inherits a constructor from SXP::Reader

Instance Method Details

- (Object) read_token

Returns:



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

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

- skip_comments

This method returns an undefined value.



20
21
22
23
24
25
26
27
28
# File 'lib/sxp/reader/extended.rb', line 20

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