Module: Campa
- Defined in:
- lib/campa.rb,
lib/campa/cli.rb,
lib/campa/core.rb,
lib/campa/list.rb,
lib/campa/node.rb,
lib/campa/repl.rb,
lib/campa/evaler.rb,
lib/campa/lambda.rb,
lib/campa/reader.rb,
lib/campa/symbol.rb,
lib/campa/context.rb,
lib/campa/lisp/eq.rb,
lib/campa/printer.rb,
lib/campa/version.rb,
lib/campa/language.rb,
lib/campa/lisp/car.rb,
lib/campa/lisp/cdr.rb,
lib/campa/core/load.rb,
lib/campa/core/test.rb,
lib/campa/lisp/atom.rb,
lib/campa/lisp/cadr.rb,
lib/campa/lisp/cond.rb,
lib/campa/lisp/cons.rb,
lib/campa/lisp/core.rb,
lib/campa/core/print.rb,
lib/campa/lisp/defun.rb,
lib/campa/lisp/label.rb,
lib/campa/lisp/quote.rb,
lib/campa/error/arity.rb,
lib/campa/lisp/list_fn.rb,
lib/campa/core/print_ln.rb,
lib/campa/error/reserved.rb,
lib/campa/lisp/lambda_fn.rb,
lib/campa/error/not_found.rb,
lib/campa/execution_error.rb,
lib/campa/core/test_report.rb,
lib/campa/error/parameters.rb,
lib/campa/error/resolution.rb,
lib/campa/error/invalid_number.rb,
lib/campa/error/not_a_function.rb,
lib/campa/error/illegal_argument.rb,
lib/campa/error/missing_delimiter.rb
Overview
Campa is a tiny LISP implementation.
The “benchmark” for this is to cover the specification established by the Paul Graham’s article The Roots of Lisp.
So the following functions are implemented in the runtime:
- (atom something)
- (car list)
- (cdr list)
- (cond (some-condition value) (another-condition another-value))
- (cons 'first '(second third))
- (defun fun-name (parameters list) 'body)
- (eq a-thing another-thing)
- (label meaning-of-life 42)
- (quote (some stuff))
Besides these core functions other two ones, also specified on The Roots of Lisp, are also implemented on tnis LISP:
- (cadr list) - and any variation possible (caaar, cadadar...)
- (list 'this 'creates 'a 'new 'list)
Those are all the functions necessary to implement an eval function able to interprete LISP by itself.
And to be sure that this is the case we have this implementation on campa/core.cmp.
Defined Under Namespace
Modules: Core, Error, Lisp Classes: Cli, Context, Evaler, ExecutionError, Lambda, Language, List, Node, Printer, Reader, Repl, Symbol
Constant Summary collapse
- CR_REGEX =
caar, cddr, cadr, but not car or cdr
/\Ac((ad)|(a|d){2,})r$$/
- SYMBOL_OUT =
symbol to reference the “stdout” in a Campa execution context
Symbol.new("__out__")
- SYMBOL_LAMBDA =
symbol for the lambda function
Symbol.new("lambda")
- SYMBOL_QUOTE =
symbol for the quote function
Symbol.new("quote")
- VERSION =
"0.1.3"
Class Method Summary collapse
-
.root ⇒ Object
Returns a Pathname pointint to the root of the “gem”.
Class Method Details
.root ⇒ Object
Returns a Pathname pointint to the root of the “gem”.
Useful for requiring and/or finding files that need to be read by the runtime.
61 62 63 |
# File 'lib/campa.rb', line 61 def self.root @root ||= Pathname.new File.(__dir__) end |