API for clojure.tools.reader - Clojure Reader 1.0.1 (in development)

by Bronsa

Full namespace name: clojure.tools.reader

Overview

A clojure reader in clojure

Public Variables and Functions



*alias-map*

dynamic var

    
Map from ns alias to ns, if non-nil, it will be used to resolve read-time
ns aliases instead of (ns-aliases *ns*).

Defaults to nil

    
    
    Source
  


map-func

function
Usage: (map-func coll)
Decide which map type to use, array-map if less than 16 elements

    
    
    Source
  


resolve-symbol

dynamic function
Usage: (resolve-symbol s)
Resolve a symbol s into its fully qualified namespace version

    
    
    Source
  

clojure.tools.reader.default-data-readers





Public Variables and Functions



parse-timestamp

var

    
Parse a string containing an RFC3339-like like timestamp.

The function new-instant is called with the following arguments.

                min  max           default
                ---  ------------  -------
  years          0           9999      N/A (s must provide years)
  months         1             12        1
  days           1             31        1 (actual max days depends
  hours          0             23        0  on month and year)
  minutes        0             59        0
  seconds        0             60        0 (though 60 is only valid
  nanoseconds    0      999999999        0  when minutes is 59)
  offset-sign   -1              1        0
  offset-hours   0             23        0
  offset-minutes 0             59        0

These are all integers and will be non-nil. (The listed defaults
will be passed if the corresponding field is not present in s.)

Grammar (of s):

  date-fullyear   = 4DIGIT
  date-month      = 2DIGIT  ; 01-12
  date-mday       = 2DIGIT  ; 01-28, 01-29, 01-30, 01-31 based on
                            ; month/year
  time-hour       = 2DIGIT  ; 00-23
  time-minute     = 2DIGIT  ; 00-59
  time-second     = 2DIGIT  ; 00-58, 00-59, 00-60 based on leap second
                            ; rules
  time-secfrac    = '.' 1*DIGIT
  time-numoffset  = ('+' / '-') time-hour ':' time-minute
  time-offset     = 'Z' / time-numoffset

  time-part       = time-hour [ ':' time-minute [ ':' time-second
                    [time-secfrac] [time-offset] ] ]

  timestamp       = date-year [ '-' date-month [ '-' date-mday
                    [ 'T' time-part ] ] ]

Unlike RFC3339:

  - we only parse the timestamp format
  - timestamp can elide trailing components
  - time-offset is optional (defaults to +00:00)

Though time-offset is syntactically optional, a missing time-offset
will be treated as if the time-offset zero (+00:00) had been
specified.

    
    
    Source
  


read-instant-calendar

var

    
To read an instant as a java.util.Calendar, bind *data-readers* to a map with
this var as the value for the 'inst key.  Calendar preserves the timezone
offset.

    
    
    Source
  


read-instant-date

var

    
To read an instant as a java.util.Date, bind *data-readers* to a map with
this var as the value for the 'inst key. The timezone offset will be used
to convert into UTC.

    
    
    Source
  


read-instant-timestamp

var

    
To read an instant as a java.sql.Timestamp, bind *data-readers* to a
map with this var as the value for the 'inst key. Timestamp preserves
fractional seconds with nanosecond precision. The timezone offset will
be used to convert into UTC.

    
    
    Source
  


validated

function
Usage: (validated new-instance)
Return a function which constructs and instant by calling constructor
after first validating that those arguments are in range and otherwise
plausible. The resulting function will throw an exception if called
with invalid arguments.

    
    
    Source
  

clojure.tools.reader.edn

An EDN reader in clojure

Public Variables and Functions



read

function
Usage: (read)
       (read reader)
       (read {:keys [eof], :as opts} reader)
       (read reader eof-error? eof opts)
Reads the first object from an IPushbackReader or a java.io.PushbackReader.
Returns the object read. If EOF, throws if eof-error? is true otherwise returns eof.
If no reader is provided, *in* will be used.

Reads data in the edn format (subset of Clojure data):
http://edn-format.org

clojure.tools.reader.edn/read doesn't depend on dynamic Vars, all configuration
is done by passing an opt map.

opts is a map that can include the following keys:
:eof - value to return on end-of-file. When not supplied, eof throws an exception.
:readers  - a map of tag symbols to data-reader functions to be considered before default-data-readers.
           When not supplied, only the default-data-readers will be used.
:default - A function of two args, that will, if present and no reader is found for a tag,
           be called with the tag and the value.

    
    
    Source
  


read-string

function
Usage: (read-string s)
       (read-string opts s)
Reads one object from the string s.
Returns nil when s is nil or empty.

Reads data in the edn format (subset of Clojure data):
http://edn-format.org

opts is a map as per clojure.tools.reader.edn/read

    
    
    Source
  

clojure.tools.reader.impl.commons





Public Variables and Functions



number-literal?

function
Usage: (number-literal? reader initch)
Checks whether the reader is at the start of a number literal

    
    
    Source
  


parse-symbol

function
Usage: (parse-symbol token)
Parses a string into a vector of the namespace and symbol

    
    
    Source
  


read-past

function
Usage: (read-past pred rdr)
Read until first character that doesn't match pred, returning
char.

    
    
    Source
  


skip-line

function
Usage: (skip-line reader)
Advances the reader to the end of a line. Returns the reader

    
    
    Source
  

clojure.tools.reader.impl.utils





Public Variables and Functions



desugar-meta

function
Usage: (desugar-meta f)
Resolves syntactical sugar in metadata

    
    
    Source
  


make-var

function
Usage: (make-var)
Returns an anonymous unbound Var

    
    
    Source
  


newline?

function
Usage: (newline? c)
Checks whether the character is a newline

    
    
    Source
  


numeric?

function
Usage: (numeric? ch)
Checks whether a given character is numeric

    
    
    Source
  


reader-conditional

function
Usage: (reader-conditional form splicing?)
Construct a data representation of a reader conditional.
If true, splicing? indicates read-cond-splicing.

    
    
    Source
  


reader-conditional?

function
Usage: (reader-conditional? value)
Return true if the value is the data representation of a reader conditional

    
    
    Source
  


tagged-literal

function
Usage: (tagged-literal tag form)
Construct a data representation of a tagged literal from a
tag symbol and a form.

    
    
    Source
  


tagged-literal?

function
Usage: (tagged-literal? value)
Return true if the value is the data representation of a tagged literal

    
    
    Source
  


whitespace?

function
Usage: (whitespace? ch)
Checks whether a given character is whitespace

    
    
    Source
  

clojure.tools.reader.reader-types





Protocols



IPushbackReader

Protocol

    Known implementations: IndexingPushbackReader, java.io.PushbackReader, PushbackReader, SourceLoggingPushbackReader
    

unread

function
Usage: (unread reader ch)
Pushes back a single character on to the stream

      
      
      
    
Source


IndexingReader

Protocol

    Known implementations: clojure.lang.LineNumberingPushbackReader, IndexingPushbackReader, SourceLoggingPushbackReader
    

get-column-number

function
Usage: (get-column-number reader)
Returns the column number of the next character to be read from the stream

      
      
      
    

get-file-name

function
Usage: (get-file-name reader)
Returns the file name the reader is reading from, or nil

      
      
      
    

get-line-number

function
Usage: (get-line-number reader)
Returns the line number of the next character to be read from the stream

      
      
      
    
Source


Reader

Protocol

    Known implementations: IndexingPushbackReader, InputStreamReader, java.io.PushbackReader, PushbackReader, SourceLoggingPushbackReader, StringReader
    

peek-char

function
Usage: (peek-char reader)
Returns the next char from the Reader without removing it from the reader stream

      
      
      
    

read-char

function
Usage: (read-char reader)
Returns the next char from the Reader, nil if the end of stream has been reached

      
      
      
    
Source

Types



IndexingPushbackReader

type

    Fields: [rdr line column line-start? prev prev-column file-name]
Protocols: IPushbackReader, IndexingReader, Reader
Interfaces: java.io.Closeable


InputStreamReader

type

    Fields: [is buf]
Protocols: Reader
Interfaces: java.io.Closeable


PushbackReader

type

    Fields: [rdr buf buf-len buf-pos]
Protocols: IPushbackReader, Reader
Interfaces: java.io.Closeable


SourceLoggingPushbackReader

type

    Fields: [rdr line column line-start? prev prev-column file-name source-log-frames]
Protocols: IPushbackReader, IndexingReader, Reader
Interfaces: java.io.Closeable


StringReader

type

    Fields: [s s-len s-pos]
Protocols: Reader
Interfaces:

Public Variables and Functions



->IndexingPushbackReader

function
Usage: (->IndexingPushbackReader rdr line column line-start? prev prev-column file-name)
Positional factory function for class clojure.tools.reader.reader_types.IndexingPushbackReader.

    
    
    Source
  


->InputStreamReader

function
Usage: (->InputStreamReader is buf)
Positional factory function for class clojure.tools.reader.reader_types.InputStreamReader.

    
    
    Source
  


->PushbackReader

function
Usage: (->PushbackReader rdr buf buf-len buf-pos)
Positional factory function for class clojure.tools.reader.reader_types.PushbackReader.

    
    
    Source
  


->SourceLoggingPushbackReader

function
Usage: (->SourceLoggingPushbackReader rdr line column line-start? prev prev-column file-name source-log-frames)
Positional factory function for class clojure.tools.reader.reader_types.SourceLoggingPushbackReader.

    
    
    Source
  


->StringReader

function
Usage: (->StringReader s s-len s-pos)
Positional factory function for class clojure.tools.reader.reader_types.StringReader.

    
    
    Source
  


indexing-push-back-reader

function
Usage: (indexing-push-back-reader s-or-rdr)
       (indexing-push-back-reader s-or-rdr buf-len)
       (indexing-push-back-reader s-or-rdr buf-len file-name)
Creates an IndexingPushbackReader from a given string or PushbackReader

    
    
    Source
  


indexing-reader?

function
Usage: (indexing-reader? rdr)
Returns true if the reader satisfies IndexingReader

    
    
    Source
  


input-stream-push-back-reader

function
Usage: (input-stream-push-back-reader is)
       (input-stream-push-back-reader is buf-len)
Creates a PushbackReader from a given InputStream

    
    
    Source
  


input-stream-reader

function
Usage: (input-stream-reader is)
Creates an InputStreamReader from an InputStream

    
    
    Source
  


line-start?

function
Usage: (line-start? rdr)
Returns true if rdr is an IndexingReader and the current char starts a new line

    
    
    Source
  


log-source

macro
Usage: (log-source reader & body)
If reader is a SourceLoggingPushbackReader, execute body in a source
logging context. Otherwise, execute body, returning the result.

    
    
    Source
  


merge-meta

function
Usage: (merge-meta obj m)
Returns an object of the same type and value as `obj`, with its
metadata merged over `m`.

    
    
    Source
  


push-back-reader

function
Usage: (push-back-reader rdr)
       (push-back-reader rdr buf-len)
Creates a PushbackReader from a given reader or string

    
    
    Source
  


read-line

function
Usage: (read-line)
       (read-line rdr)
Reads a line from the reader or from *in* if no reader is specified

    
    
    Source
  


reader-error

function
Usage: (reader-error rdr & msg)
Throws an ExceptionInfo with the given message.
If rdr is an IndexingReader, additional information about column and line number is provided

    
    
    Source
  


source-logging-push-back-reader

function
Usage: (source-logging-push-back-reader s-or-rdr)
       (source-logging-push-back-reader s-or-rdr buf-len)
       (source-logging-push-back-reader s-or-rdr buf-len file-name)
Creates a SourceLoggingPushbackReader from a given string or PushbackReader

    
    
    Source
  


string-push-back-reader

function
Usage: (string-push-back-reader s)
       (string-push-back-reader s buf-len)
Creates a PushbackReader from a given string

    
    
    Source
  


string-reader

function
Usage: (string-reader s)
Creates a StringReader from a given string

    
    
    Source
  
Logo & site design by Tom Hickey.
Clojure auto-documentation system by Tom Faulhaber.