SExpressions.jl
SExpressions.jl includes a roughly Racket-compatible parser for s-expressions.
Lists
SExpressions.Lists.cdr
— MethodThe tail of a List
.
Note that the tail need not be a list (or even a List
) if the list is improper.
SExpressions.Lists.islist
— MethodReturn true
if the provided List
is in fact a list, i.e., it is not improper.
This is the case if the list is a Nil
(empty list) or a Cons
with a proper list as its tail.
SExpressions.Lists.Cons
— TypeAn object which is essentially a pair of two objects.
The two objects are referred to, for historical reasons, as car
and cdr
.These abbreviations are not semantically relevant today, so can generally be thought of as the head object and the tail object. For Cons
objects which are (proper) lists, the car
(head) object will be the first element of the list, and the cdr
(tail) object will be a list representing the remaining elements.
SExpressions.Lists.Nil
— TypeAn object representing nothing, or an empty list.
The singleton instance of this type is called nil
. This type is isomorphic to, and very similar, to Nothing
. However, it is often useful to distinguish the nil
used within many lisp dialects from a true Nothing
, because nil
is iterable and represents an empty list.
SExpressions.Lists.unparse
— MethodConvenience function to produce compact strings from (proper) lists of lisp objects.
Core Parser Interface
SExpressions.Parser.parse
— Functionparse(s::AbstractString)
Read the given string s
as a single s-expression. The alternative vocabulary Base.parse(SExpression, s)
is also supported and may be preferred.
parse(io::IO)
Read a single object from the given io
stream.
SExpressions.Parser.parseall
— Functionparseall(io::IO)
parseall(s::AbstractString)
Parse all objects from the given stream or string into a single list.
SExpressions.Parser.parsefile
— Functionparsefile(filename::AbstractString)
Parse a file into a single list.