All Projects → picrin-scheme → libpicrin

picrin-scheme / libpicrin

Licence: other
Super Tiny Scheme Interpreter for Freestanding Environment

Programming Languages

c
50402 projects - #5 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to libpicrin

tinypacks
A data serialization format for constrained environments like 8-bit and 16-bit microcontrollers.
Stars: ✭ 30 (-44.44%)
Mutual labels:  embedded
OpenWare
Firmware for OWL devices
Stars: ✭ 23 (-57.41%)
Mutual labels:  embedded
esp-idf-hal
embedded-hal implementation for Rust on ESP32 and ESP-IDF
Stars: ✭ 42 (-22.22%)
Mutual labels:  embedded
dd performances
DeepDetect performance sheet
Stars: ✭ 92 (+70.37%)
Mutual labels:  embedded
static string
A fixed capacity dynamically sized string
Stars: ✭ 46 (-14.81%)
Mutual labels:  embedded
eze
Embedded Zeebe Engine
Stars: ✭ 13 (-75.93%)
Mutual labels:  embedded
mbedtls-esp8266
Updated and Upgraded mbedTLS library for the ESP8266 (probably ESP32 too)
Stars: ✭ 13 (-75.93%)
Mutual labels:  embedded
cortex-uni-startup
Unified startup code and link scripts for Cortex-M microcontrollers
Stars: ✭ 33 (-38.89%)
Mutual labels:  embedded
wymlp
tiny fast portable real-time deep neural network for regression and classification within 50 LOC.
Stars: ✭ 36 (-33.33%)
Mutual labels:  embedded
Cicada-FW
IoT Communications Module for Energy Access. An easy way to get production ready, bi-directional communications for your IoT embedded device. Proiect supported by the EnAccess Foundation - https://enaccess.org
Stars: ✭ 12 (-77.78%)
Mutual labels:  embedded
Ellie-Language
Ellie is a type-safe programing language that runs on embedded and sandboxed environments.
Stars: ✭ 16 (-70.37%)
Mutual labels:  embedded
mros2
agent-less and lightweight communication library compatible with rclcpp for embedded devices
Stars: ✭ 72 (+33.33%)
Mutual labels:  embedded
go-jdk
Run JVM-based code in Go efficiently
Stars: ✭ 61 (+12.96%)
Mutual labels:  embedded
ArduinoSpritzCipher
Spritz encryption system portable C library, CSPRNG, cryptographic hash and MAC functions, symmetric-key data encryption, and general-purpose functions. It's also an Arduino library.
Stars: ✭ 67 (+24.07%)
Mutual labels:  embedded
pwm-pca9685-rs
Platform-agnostic Rust driver for the PCA9685 I2C 16-channel, 12-bit PWM/Servo/LED controller
Stars: ✭ 19 (-64.81%)
Mutual labels:  embedded
oic
Open Instrument Control
Stars: ✭ 40 (-25.93%)
Mutual labels:  embedded
apex
Apex RTOS - A (somewhat) Linux compatible real time operating system
Stars: ✭ 15 (-72.22%)
Mutual labels:  embedded
epsilon-sample-app-rust
A sample Rust app for the NumWorks graphing calculator
Stars: ✭ 16 (-70.37%)
Mutual labels:  embedded
b9
An educational JS virtual machine based on Eclipse OMR
Stars: ✭ 40 (-25.93%)
Mutual labels:  gc
sabotage
a radical and experimental distribution based on musl libc and busybox
Stars: ✭ 502 (+829.63%)
Mutual labels:  embedded

libpicrin

libpicrin is a super tiny scheme interpreter intended to be embedded in other applications such as game engine and network server. It provides a subset language of R7RS with several useful extensions. By default, libpicrin only contains some C files and headers and this README file. To embed, you only need to copy the files into the project and add include dir to the include path.

Originally, libpicrin used to be the core component of Picrin Scheme. They are currently maintained at separate repositories.

Example

#include <stdio.h>

#include "picrin.h"
#include "picrin/extra.h"

/* Simple REPL program */

int
main(int argc, char *argv[])
{
  pic_state *pic;
  pic_value expr;

  pic = pic_open(pic_default_allocf, NULL);

  while (1) {
    printf("> ");

    expr = pic_read(pic, pic_stdin(pic));

    if (pic_eof_p(pic, expr)) {
      break;
    }

    pic_printf(pic, "~s\n", pic_eval(pic, expr, "picrin.user"));
  }

  pic_close(pic);

  return 0;
}

More Example

Function binding is also easy. pic_defun defines a scheme procedure converting from a C function. In the native function, callee arguments can be taken with pic_get_args. pic_get_args gets arguments according to the format string. If actual arguments does not match a number or incompatible types, it will raise an exception.

#include "picrin.h"
#include "picrin/extra.h"

int fact(int i) {
  return i == 1 ? 1 : i * fact(i - 1);
}

pic_value factorial(pic_state *pic) {
  int i;

  pic_get_args(pic, "i", &i);

  return pic_int_value(pic, fact(i));
}

int
main(int argc, char *argv[])
{
  pic_state *pic = pic_open(pic_default_allocf, NULL);

  pic_defun(pic, "fact", factorial); /* define fact procedure */

  pic_load_cstr(pic, "(display (fact 10))");

  pic_close(pic);

  return 0;
}

Language

All procedures and syntaces are exported from a single library named (picrin base). The complete list is found at https://gist.github.com/wasabiz/344d802a2340d1f734b7 .

call/cc

Full continuation has many problems in embbeding into applications. By default, libpicrin's call/cc operator does not support continuation that can handle re-entering (it only supports escape continuations). To remove this restriction, please use an add-on provided from Picrin Scheme's repository.

Strings

libpicrin utilize rope data structure to implement string type. Thanks to the implementation, string-append is guaranteed to be done in a constant time (so do string-copy, when ascii-only mode is enabled). In return for that, strings in libpicrin are immutable by default. It does not provide mutation API (string-set!, string-copy! and string-fill! in R7RS). This restriction can be also removed with an add-on in Picrin Scheme's repository.

Dictionaries

Dictionary is a hash table from symbol to object.

Authors

See https://github.com/picrin-scheme/picrin for details.

LICENSE

Copyright (c) 2013-2017 Yuichi Nishiwaki and other picrin contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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].