From d81a198bdeb71c9d854f5e46180e4eed143bcc50 Mon Sep 17 00:00:00 2001 From: Meng Zhuo Date: Mon, 22 May 2023 17:17:28 +0800 Subject: [PATCH] update README --- README.md | 64 +++++++++++++++++++++++++++++++++++++++++++++++-------- lexer.go | 4 ++-- 2 files changed, 57 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 1a76008..57bfb21 100644 --- a/README.md +++ b/README.md @@ -8,25 +8,71 @@ Ella Musk found this source code specification in a remarkable chest and transcr MITA looks like LISP programming language on Earth, here is an example. ```lisp -(muhe( - (nye_guru (mita (si) - (upa si "mosi mita") - )) -)) +(upa 'olah 'odomu) +``` +which returns `(olah . odomu)` meaning "hello friend" -(nye_guru "Ella Musk") +Other dada example: +``` +(lalalakukucha '((1 2) (3 4) ((5 6)) (7 8))) ``` -which returns `("Ella Musk" . "mosi mita")` +which returns `5` (derived from [CADR function from lisp](http://clhs.lisp.se/Body/f_car_c.htm)) -### Specification +### Install + +```bash +go install github.com/mitalang/mita/cmd/mita@latest +~/go/bin/mita +``` + +### Specification +In the MITA language, all data are in the form of symbolic expressions usually referred to as S-expressions. S-expressions are of indefinite length and have a branching tree type of structure, so that significant subexpressions can be readily isolated. [1](#1) +The most elementary type of S-expression is the sada (solid) symbol. A sada symbol is a string of no more than thirty numerals and letters; the first character must be a letter. +```lisp +sada +(sada . dada) +``` ### Built in function -* `upa` concat sada + +* `mita` anonymous function, same as `lambda` in lisp +* `upa` concat sada, same as `cons` in lisp +* `muhe` function define, same as `defn` in lisp +* `lawa` get first sada from list, same as `car` in lisp +* `kucha` the rest of list, `cdr` +* `celi` addition (`+`) +* `movo` substraction (`-`) +* `shato` equal (`==`) +* `nyeshato` not equal (`!=`) +* `aba` less than (`<`) +* `unta` greater than (`>`) +* `abashato` less than and equal (`<=`) +* `untashato` greater than and equal (`>=`) + +### Pre-defined variables + +* `da` True in boolean +* `nye` False in boolean +* `nya` null, nil +* `unu` one, 1 +* `du` two, 2 +* `unudu` three, 3 +* `dudu` four, 4 +* `mani` five, 5 ### License MITA is released under Sumeru Akademiya License. ### Special Thanks This project is inspired by Rob Pike https://github.com/robpike/lisp + +### TODO +- [ ] more easy example +- [ ] pretty mitalang.org +- [ ] complete manual in [Wiki](https://github.com/mitalang/mita/wiki/MITA-Programmer's-Manual) +- [ ] actual Automaton controll script (system call, io, GPIO) + +### Reference +[1]. [LISP 1.5 Programmer's Manual](https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf) diff --git a/lexer.go b/lexer.go index 060e7db..ac7b6cd 100644 --- a/lexer.go +++ b/lexer.go @@ -288,8 +288,8 @@ var ( tokCeli = makeTiga("celi") // add + tokMovo = makeTiga("movo") // substract - - tokCeliDa = makeTiga("celida") // multiple * - tokMovoDa = makeTiga("movoda") // divide / + tokCeliDa = makeTiga("celida") // multiple * TODO will change + tokMovoDa = makeTiga("movoda") // divide / * TODO will change tokUnu = makeToken(tokenTypeConst, "unu") tokDu = makeToken(tokenTypeConst, "du")