sophia

command module
v0.0.0-...-f49f154 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 20, 2024 License: MIT Imports: 1 Imported by: 0

README

Sophia

My take on a small lisp like embeddable programming language with go interoperability.

View the docs containing an overview, an in depth overview and a lot of Examples here

(let arr 1 2 3 4 5)

(fun square [n] (* n n))
(map (square) arr) ;; [1 4 9 16 25]

(filter
    (lambda [n]
        (= (% n 2) 0)) arr) ;; [2 4]

(let person {
    array: [1 2 3]
    bank: {
        institute: {
            name: "western union"
        }
    }
})
(println person#["array"][0]) ;; 1
(println person#["bank"]["institute"]["name"]) ;; "western union"

(let name "anon")
(println 'Hello {name}!')

Try

Running
git clone https://github.com/xnacly/sophia
go build

With a file:

$ sophia ./examples/helloworld.phia

Hello World!

With an expression:

$ sophia -exp '(println "Hello World")'

Hello World!
$ echo '(println "Hello World")' | sophia

Hello World!

As a repl:

$ sophia

  ██████  ▒█████   ██▓███   ██░ ██  ██▓ ▄▄▄
▒██    ▒ ▒██▒  ██▒▓██░  ██▒▓██░ ██▒▓██▒▒████▄
░ ▓██▄   ▒██░  ██▒▓██░ ██▓▒▒██▀▀██░▒██▒▒██  ▀█▄
  ▒   ██▒▒██   ██░▒██▄█▓▒ ▒░▓█ ░██ ░██░░██▄▄▄▄██
▒██████▒▒░ ████▓▒░▒██▒ ░  ░░▓█▒░██▓░██░ ▓█   ▓██▒
▒ ▒▓▒ ▒ ░░ ▒░▒░▒░ ▒▓▒░ ░  ░ ▒ ░░▒░▒░▓   ▒▒   ▓▒█░
░ ░▒  ░ ░  ░ ▒ ▒░ ░▒ ░      ▒ ░▒░ ░ ▒ ░  ▒   ▒▒ ░
░  ░  ░  ░ ░ ░ ▒  ░░        ░  ░░ ░ ▒ ░  ░   ▒
      ░      ░ ░            ░  ░  ░ ░        ░  ░

Welcome to the Sophia programming language repl - press <CTRL-D> or <CTRL-C> to quit...
sophia> (let person { name: "user" })
= [user]
sophia> (println "Hello World," person#["name"] ":)")
Hello World, user :)
= [<nil>]
sophia>

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
builtin
builtin provides functions that are built into the sophia language but are written in pure go, they may interface with the sophia lang via AST manipulation and by accepting AST nodes and returning values or nodes.
builtin provides functions that are built into the sophia language but are written in pure go, they may interface with the sophia lang via AST manipulation and by accepting AST nodes and returning values or nodes.
run
serror
Provides functionality for bubbling internal errors up to the user in a pretty and concise way
Provides functionality for bubbling internal errors up to the user in a pretty and concise way
embed provides helpers and abstractions over the github.com/xnacly/sophia runtime for easily embedding the runtime and registering functions via the known function interface.
embed provides helpers and abstractions over the github.com/xnacly/sophia runtime for easily embedding the runtime and registering functions via the known function interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL