Signo (Signo v0.0.2)
View SourceSigno is a beautifully elegant Lisp-like language, written in Elixir.
This module contains the public (Elixir) API for evaluating Signo programs. Check out the "Pages" tab in the left-hand corner for details on installing and running the interpreter, along with a detailed guide to the Signo language.
You'll mainly be using eval_file!/1 and eval_source!/1, or a CLI abstraction
of them, for compiling and interpreting your Signo source code. However, for more
advanced usecases, we also expose individual compiler steps, such as lex!/1,
parse!/1, evaluate!/1.
See "mix tasks" in the left-hand corner for details on command-line usage.
Summary
Functions
Compiles and evaluates a Signo source file.
Compiles and evaluates a string of Signo source code.
Same as evaluate!/1, but operates on an existing scope instead of
intializing a new one.
Lexes a string containing valid Signo source code into
a list of Signo.Tokens.
Parses a list of Signo.Tokens into a executable AST.
Starts a REPL (read-evaluate-print loop) session.
Returns the Signo version string.
Functions
@spec eval_file!(Path.t()) :: {Signo.AST.value(), Signo.Env.t()}
Compiles and evaluates a Signo source file.
Examples
iex> Signo.eval_file!("./main.sg")
hello, world!
{%AST.String{value: "hello world"}, %Signo.Env{...}}
@spec eval_source!(String.t()) :: {Signo.AST.value(), Signo.Env.t()}
Compiles and evaluates a string of Signo source code.
Examples
iex> Signo.eval_source!("(print 69)")
69
{%AST.Atom{value: :ok}, %Signo.Env{...}}
@spec evaluate!(Signo.AST.t()) :: {Signo.AST.value(), Signo.Env.t()}
Evaluates a Signo.AST into a Signo.Env containing final
global scope, and executes any side-effects.
See "Exceptions" for potential exceptions that can be raised.
@spec evaluate!(Signo.AST.t(), Signo.Env.t()) :: {Signo.AST.value(), Signo.Env.t()}
Same as evaluate!/1, but operates on an existing scope instead of
intializing a new one.
Primarily used to facilitate REPL-like programs, but can be applied in other contexts as well.
@spec lex!(String.t()) :: [Signo.Token.t()]
Lexes a string containing valid Signo source code into
a list of Signo.Tokens.
Raises Signo.LexError when encountering unknown characters.
Multiple lines are supported.
@spec parse!([Signo.Token.t()]) :: Signo.AST.t()
Parses a list of Signo.Tokens into a executable AST.
Raises Signo.ParseError when encountering unexpected tokens.
Starts a REPL (read-evaluate-print loop) session.
Examples
Erlang/OTP 26 [erts-14.2.1] [source] [64-bit] [smp:11:11] [ds:11:11:10] [async-threads:1] [jit]
Interactive Signo v0.1.0 (Elixir/1.16.2)
sig(1)> (print "hello world")
hello world
sig(2)>
@spec sigil_l(String.t(), term()) :: Signo.AST.t()
Shorthand for lex!/1 and parse!/1.
Given a string of Signo source code, returns a valid
AST that can be evaluated using evaluate!/1.
Examples
iex> evaluate!(~l"(print 10)")
{%Signo.AST.Atom{value: :ok}, %Signo.AST.Env{}}
@spec version() :: String.t()
Returns the Signo version string.