Sammal v0.1.0 Sammal.ParserV2 View Source

A parser for Sammal based on parser combinators.

Grammar

primitive   : number | symbol | string
form:       : ( expression* )
expression  : quoted | primitive | form
quoted      : ' expression
sammal      : expression+

Link to this section Summary

Functions

Parse an expression - either a form or a primitive

Parse parenthesis-enclosed forms

Parse a number

Parse a primitive expression

Parse and extend a quoted expression

Parse a Sammal program

Parse a string

Parse a symbol

Parse a Sammal.Expr struct that matches a given value or predicate

Link to this section Types

Link to this type error() View Source
error() :: atom
Link to this type parser() View Source
parser() :: (input :: [Sammal.Expr] -> {:ok, result} | {:error, error})
Link to this type result() View Source
result() :: {value :: [Sammal.Expr], remaining :: [Sammal.Expr]}

Link to this section Functions

Link to this function expression() View Source
expression() :: parser

Parse an expression - either a form or a primitive.

Parse parenthesis-enclosed forms.

Parse a number.

Parse a primitive expression.

Parse and extend a quoted expression.

Parse a Sammal program.

Parse a string.

Parse a symbol.

Link to this function token(value_or_predicate, error \\ :unexpected) View Source
token(any | (any -> boolean), error) :: parser

Parse a Sammal.Expr struct that matches a given value or predicate.