Berry

Berry, un piccolo linguaggio di scripting a oggetti nato per i microcontrollori: prompt interattivo e script. Scrivi berry per il prompt, berry script.be per eseguire un file da /sdcard/home.

versione 1.1.0 · Licenza: MIT · Sito del progetto

Berry

A cosa serve

Berry è un linguaggio di scripting piccolo e veloce, pensato per i microcontrollori (è quello che usa Tasmota): classi, closure, eccezioni, liste e mappe, moduli per stringhe, matematica, JSON e file. Qui hai il prompt interattivo e l'esecuzione di file .be.

Come si usa

Comando Cosa fa
berry apre il prompt interattivo (>)
berry script.be esegue un file dalla cartella home
berry -i script.be esegue il file e poi resta nel prompt
berry -e "print(6*7)" esegue una riga al volo

Nel prompt scrivi un'espressione o un'istruzione e premi Invio; un blocco lasciato aperto (def, for, if...) continua alla riga dopo con >>:

> 6 * 7
42
> def quadrato(x) return x * x end
> quadrato(12)
144
> import math
> math.sqrt(2)
1.41421
> try raise "errore", "qualcosa" except .. as e, m print(e, m) end
errore qualcosa

File e JSON:

f = open("/note.txt", "w") f.write("ciao") f.close()
import json
print(json.dump({"a": [1, 2]}))

Per uscire: EOF, oppure import os os.exit().

Limiti

Niente processi esterni: os.system risponde -1. Niente moduli nativi caricabili (.so). Memoria disponibile: fino a 8 MB.

Nel Terminale

Berry

Berry, a small object-oriented scripting language for microcontrollers: interactive prompt and scripts. Type berry for the prompt, berry script.be to run a file from /sdcard/home.

version 1.1.0 · License: MIT · Project site

Berry

What it is

Berry is a small, fast scripting language made for microcontrollers (Tasmota uses it): classes, closures, exceptions, lists and maps, modules for strings, math, JSON and files. You get the interactive prompt and .be file execution.

How to use it

Command What it does
berry opens the interactive prompt (>)
berry script.be runs a file from the home folder
berry -i script.be runs the file, then stays at the prompt
berry -e "print(6*7)" runs one line

At the prompt type an expression or a statement and press Enter; a block left open (def, for, if...) continues on the next line with >>:

> 6 * 7
42
> def square(x) return x * x end
> square(12)
144
> import math
> math.sqrt(2)
1.41421
> try raise "oops", "something" except .. as e, m print(e, m) end
oops something

Files and JSON:

f = open("/notes.txt", "w") f.write("hello") f.close()
import json
print(json.dump({"a": [1, 2]}))

To quit: EOF, or import os os.exit().

Limits

No external processes: os.system answers -1. No loadable native modules (.so). Memory: up to 8 MB.

In the Terminal