You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
Clyne Sullivan d31f2c9aa6 Update README.md 7 years ago
tests tests to folder 7 years ago
.gitignore indent fixes, nested conditionals 7 years ago
LICENSE Added shell and licensing 7 years ago
Makefile Added shell and licensing 7 years ago
README.md Update README.md 7 years ago
builtins.c single-letter vars, size & append, string indexing 7 years ago
builtins.h documentation, error fixes, organization 7 years ago
calc change load/run style, hunt for memory leaks 7 years ago
error.c documentation, error fixes, organization 7 years ago
error.h documentation, error fixes, organization 7 years ago
ops.c single-letter vars, size & append, string indexing 7 years ago
ops.h arrays, implicit multiply 7 years ago
parser.c single-letter vars, size & append, string indexing 7 years ago
parser.h change load/run style, hunt for memory leaks 7 years ago
shell.c.bak change load/run style, hunt for memory leaks 7 years ago
string.c documentation, error fixes, organization 7 years ago
string.h documentation, error fixes, organization 7 years ago
variable.c documentation, error fixes, organization 7 years ago
variable.h arrays, implicit multiply 7 years ago

README.md

interpreter

interpreter is a minimal scripting language aimed at low-spec embedded systems.

Many other scripting languages currently exist for embedded use, including Lua, Tcl, and BASIC; however, their implementations require certain system calls (e.g. read()/write()) that may not be available or used on an embedded device. As a result, interpreter was made with the goal to allow advanced scripts to be run in minimal conditions. This included things like having only a few built-in functions, and only loading script from C-strings one at a time.

To use interpreter with your own device, you will need some malloc/free implementation and a freestanding standard library. Newlib can work well for this, although functions like atoi() and snprintf() will probably need to be rewritten (if you don't have an _sbrk defined).

interpreter features:

  • Variable/function definition - in C and in script
  • if/else conditionals
  • while loops
  • a solve function to parse strings at script runtime

inconvenient features:

  • some code formatting is enforced due to parser limitation
  • all variables are global
  • whitespace is not always ignored

some TODO items:

  • add better error messages
  • better array support
  • for loops
  • variable scopes

building and running

This project can be made for the host system (mv shell.c.bak shell.c; make) or an ARM system (mv shell.c shell.c.bak; make arm). Make's -j argument may be used to multithread compilation.

To run on the host system, run ./shell some_script_file. Note that no IO functions are built in, so you must define your own.
To use on an ARM device, simply link libinterp.a into your program and use the header files. See shell.c for an idea of how to the interpreter.

 

This project is still in heavy development, so don't expect too much. See the wiki for a scripting guide.