Lispex v0.1.0 Parse View Source
Tokenizer and parser for the Lisp source code
Link to this section Summary
Functions
Converts a String token to its atomic form
Turns the given Lisp program into an Abstract syntax tree by calling tokenize/1
and recursively calling ‘parse/2’ a private function in the Parse
module
Splits the lisp source code by spaces. Ensures spaces between ‘(‘ and ‘)’ by replacing them with ‘ ( ‘ and ‘ ) ‘
Link to this section Functions
Converts a String token to its atomic form.
Returns Integer
, Float
or an Atom
Parameters
- token :
String
token
Turns the given Lisp program into an Abstract syntax tree by calling tokenize/1
and recursively calling ‘parse/2’ a private function in the Parse
module.
Returns List
Parameters
- program :
String
Lisp source code
Example
iex> Lispex.parse("(begin (define r 10) (* pi (* r r)))")
[["begin", ["define", "r", 10], ["*", "pi", ["*", "r", "r"]]]]
Splits the lisp source code by spaces. Ensures spaces between ‘(‘ and ‘)’ by replacing them with ‘ ( ‘ and ‘ ) ‘.