All Projects → Skiars → Berry

Skiars / Berry

Licence: mit
A ultra-lightweight embedded scripting language optimized for microcontrollers.

Programming Languages

c
50402 projects - #5 most used programming language
language
365 projects

Projects that are alternatives of or similar to Berry

Nrf Hal
A Rust HAL for the nRF family of devices
Stars: ✭ 186 (-9.71%)
Mutual labels:  microcontroller, embedded
Serial Studio
Multi-purpose serial data visualization & processing program
Stars: ✭ 1,168 (+466.99%)
Mutual labels:  microcontroller, embedded
Utensor cgen
C++ code generator for uTensor https://utensor-cgen.readthedocs.io/en/latest/
Stars: ✭ 42 (-79.61%)
Mutual labels:  microcontroller, embedded
Littlefs
A little fail-safe filesystem designed for microcontrollers
Stars: ✭ 2,488 (+1107.77%)
Mutual labels:  microcontroller, embedded
Tiny Json
The tiny-json is a versatile and easy to use json parser in C suitable for embedded systems. It is fast, robust and portable.
Stars: ✭ 127 (-38.35%)
Mutual labels:  microcontroller, embedded
Platformio Vscode Ide
PlatformIO IDE for VSCode: The next generation integrated development environment for IoT
Stars: ✭ 676 (+228.16%)
Mutual labels:  microcontroller, embedded
Daplink
Stars: ✭ 1,162 (+464.08%)
Mutual labels:  microcontroller, embedded
Embox
Modular and configurable OS for embedded applications
Stars: ✭ 576 (+179.61%)
Mutual labels:  microcontroller, embedded
Utensor
TinyML AI inference library
Stars: ✭ 1,295 (+528.64%)
Mutual labels:  microcontroller, embedded
Lv drivers
TFT and touch pad drivers for LVGL embedded GUI library
Stars: ✭ 84 (-59.22%)
Mutual labels:  microcontroller, embedded
Lvgl
Powerful and easy-to-use embedded GUI library with many widgets, advanced visual effects (opacity, antialiasing, animations) and low memory requirements (16K RAM, 64K Flash).
Stars: ✭ 8,172 (+3866.99%)
Mutual labels:  microcontroller, embedded
Lib Python
Blynk IoT library for Python and Micropython
Stars: ✭ 140 (-32.04%)
Mutual labels:  microcontroller, embedded
Guilite
✔️The smallest header-only GUI library(4 KLOC) for all platforms
Stars: ✭ 5,841 (+2735.44%)
Mutual labels:  microcontroller, embedded
Awesome Embedded
A curated list of awesome embedded programming.
Stars: ✭ 831 (+303.4%)
Mutual labels:  microcontroller, embedded
Incubator Nuttx
Apache NuttX is a mature, real-time embedded operating system (RTOS)
Stars: ✭ 591 (+186.89%)
Mutual labels:  microcontroller, embedded
Incubator Nuttx Apps
Apache NuttX Apps is a collection of tools, shells, network utilities, libraries, interpreters and can be used with the NuttX RTOS
Stars: ✭ 65 (-68.45%)
Mutual labels:  microcontroller, embedded
Platformio Core
PlatformIO is a professional collaborative platform for embedded development 👽 A place where Developers and Teams have true Freedom! No more vendor lock-in!
Stars: ✭ 5,539 (+2588.83%)
Mutual labels:  microcontroller, embedded
Pyocd
Open source Python library for programming and debugging Arm Cortex-M microcontrollers
Stars: ✭ 550 (+166.99%)
Mutual labels:  microcontroller, embedded
Sming
Sming - Open Source framework for high efficiency native ESP8266 development
Stars: ✭ 1,197 (+481.07%)
Mutual labels:  microcontroller, embedded
Chino Os
A real time operating system for IoT written in C++
Stars: ✭ 139 (-32.52%)
Mutual labels:  microcontroller, embedded

Berry

The Berry Script Language.

Introduction

Berry is a ultra-lightweight dynamically typed embedded scripting language. It is designed for lower-performance embedded devices. The Berry interpreter-core's code size is less than 40KiB and can run on less than 4KiB heap (on ARM Cortex M4 CPU, Thumb ISA and ARMCC compiler).

The interpreter of Berry include a one-pass compiler and register-based VM, all the code is written in ANSI C99. In Berry not every type is a class object. Some simple value types, such as int, real, boolean and string are not class object, but list, map and range are class object. This is a consideration about performance. Register-based VM is the same meaning as above.

Berry has the following advantages:

  • Lightweight: A well-optimized interpreter with very little resources. Ideal for use in microprocessors.
  • Fast: optimized one-pass bytecode compiler and register-based virtual machine.
  • Powerful: supports imperative programming, object-oriented programming, functional programming.
  • Flexible: Berry is a dynamic type script, and it's intended for embedding in applications. It can provide good dynamic scalability for the host system.
  • Simple: simple and natural syntax, support garbage collection, and easy to use FFI (foreign function interface).
  • RAM saving: With compile-time object construction, most of the constant objects are stored in read-only code data segments, so the RAM usage of the interpreter is very low when it starts.

Documents

LaTeX documents repository: https://github.com/Skiars/berry_doc

Short Manual: berry_short_manual.pdf.

Reference Manual: berry_rm_en_us.pdf, berry_rm_zh_cn.pdf.

Berry's EBNF grammar definition: tools/grammar/berry.ebnf

Features

  • Base Type
    • Nil: nil
    • Boolean: true and false
    • Numerical: Integer (int) and Real (real)
    • String: Single quotation-mark string and double quotation-mark string
    • Class: Instance template, read only
    • Instance: Object constructed by class
    • Module: Read-write key-value pair table
    • List: Ordered container, like [1, 2, 3]
    • Map: Hash Map container, like { 'a': 1, 2: 3, 'map': {} }
    • Range: include a lower and a upper integer value, like 0..5
  • Operator and Expression
    • Assign operator: =, +=, -=, *=, /=, %=, &=, |=, ^=, <<=, >>=
    • Relational operator: <, <=, ==, !=, >, >=
    • Logic operator: &&, ||, !
    • Arithmetic operator: +, -, *, /, %
    • Bitwise operator: &, |, ~, ^, <<, >>
    • Field operator: .
    • Subscript operator: []
    • Connect string operator: +
    • Conditional operator: ? :
    • Brackets: ()
  • Control Structure
    • Conditional statement: if-else
    • Iteration statement: while and for
    • Jump statement: break and continue
  • Function
    • Local variable and block scope
    • Return statement
    • Nested functions definition
    • Closure based on Upvalue
    • Anonymous function
    • Lambda expression
  • Class
    • Inheritance (only public single inheritance)
    • Method and Operator Overload
    • Constructor method
    • Destructive method
  • Module Management
    • Built-in module that takes almost no RAM
    • Extension module support: script module, bytecode file module and shared library (like *.so, *.dll) module
  • GC (Garbage collection)
    • Mark-Sweep GC
  • Exceptional Handling
    • Throw any exception value using the raise statement
    • Multiple catch mode
  • Bytecode file support
    • Export function to bytecode file
    • Load the bytecode file and execute

Build and Run

  1. Install the readline library (Windows does not need):

    sudo apt install libreadline-dev # Ubuntu
    brew install readline            # MacOS
    
  2. Build (The default compiler is GCC):

    make
    
  3. Run:

    ./berry # Bash or PowerShell
    berry   # Windows CMD
    
  4. Install (Only Unix-like):

    make install
    

Editor pulgins

Visual Studio Code pulgin are in this directory: ./tools/pulgins/vscode.

Examples

After compiling successfully, use the berry command with no parameters to enter the REPL environment:

Berry 0.0.1 (build in Dec 24 2018, 18:12:49)
[GCC 8.2.0] on Linux (default)
>

Now enter this code:

print("Hello world!")

You will see this output:

Hello world!

You can copy this code to the REPL:

def fib(x)
    if x <= 1
        return x
    end
    return fib(x - 1) + fib(x - 2)
end
fib(10)

This example code will output the result 55 and you can save the above code to a plain text file (eg test.be) and run this command:

./berry test.be

This will also get the correct output.

License

Berry is free software distributed under the MIT license.

The Berry interpreter partly referred to Lua's design. View Lua's license here: http://www.lua.org/license.html.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].