All Projects → paladin-t → My_basic

paladin-t / My_basic

Licence: mit
A lightweight BASIC interpreter written in standard C in dual files. Aims to be embeddable, extendable and portable.

Programming Languages

c
50402 projects - #5 most used programming language
basic
69 projects

Projects that are alternatives of or similar to My basic

Dascript
daScript - high-performance statically strong typed scripting language
Stars: ✭ 259 (-18.04%)
Mutual labels:  interpreter
Jace
Jace.NET is a calculation engine for the .NET platform.
Stars: ✭ 296 (-6.33%)
Mutual labels:  interpreter
Clojush
The Push programming language and the PushGP genetic programming system implemented in Clojure.
Stars: ✭ 305 (-3.48%)
Mutual labels:  interpreter
Swiftpascalinterpreter
Simple Swift interpreter for the Pascal language inspired by the Let’s Build A Simple Interpreter article series.
Stars: ✭ 270 (-14.56%)
Mutual labels:  interpreter
Rascal
The implementation of the Rascal meta-programming language (including interpreter, type checker, parser generator, compiler and JVM based run-time system)
Stars: ✭ 284 (-10.13%)
Mutual labels:  interpreter
Makejs
A sub Javascript interpreter for interpreting itself
Stars: ✭ 297 (-6.01%)
Mutual labels:  interpreter
balloon-lang
The Balloon programming language and interpreter.
Stars: ✭ 17 (-94.62%)
Mutual labels:  interpreter
Goby
Goby - Yet another programming language written in Go
Stars: ✭ 3,296 (+943.04%)
Mutual labels:  interpreter
Lbforth
Self-hosting metacompiled Forth, bootstrapping from a few lines of C; targets Linux, Windows, ARM, RISC-V, 68000, PDP-11, asm.js.
Stars: ✭ 293 (-7.28%)
Mutual labels:  interpreter
Rbpf
Rust virtual machine and JIT compiler for eBPF programs
Stars: ✭ 306 (-3.16%)
Mutual labels:  interpreter
Melang
A script language of preemptive scheduling coroutine in single thread
Stars: ✭ 273 (-13.61%)
Mutual labels:  interpreter
Eval5
A JavaScript interpreter written in TypeScript - Support ES5
Stars: ✭ 281 (-11.08%)
Mutual labels:  interpreter
Awesome Graal
A curated list of awesome resources for Graal, GraalVM, Truffle and related topics
Stars: ✭ 302 (-4.43%)
Mutual labels:  interpreter
Schemy
A lightweight embeddable Scheme-like interpreter for configuration
Stars: ✭ 269 (-14.87%)
Mutual labels:  interpreter
Calculatex
in progress pretty printing calculator language
Stars: ✭ 302 (-4.43%)
Mutual labels:  interpreter
pascal-interpreter
A simple interpreter for a large subset of Pascal language written for educational purposes
Stars: ✭ 21 (-93.35%)
Mutual labels:  interpreter
Csml Engine
🦜 Conversational Standard Meta Language
Stars: ✭ 292 (-7.59%)
Mutual labels:  interpreter
Partcl
ParTcl - a micro Tcl implementation
Stars: ✭ 313 (-0.95%)
Mutual labels:  interpreter
Umka Lang
Umka: a statically typed embeddable scripting language
Stars: ✭ 308 (-2.53%)
Mutual labels:  interpreter
Enso Archive
Looking for Enso, the visual programming language? ➡️ https://github.com/enso-org/enso
Stars: ✭ 305 (-3.48%)
Mutual labels:  interpreter
 _____ __ __     _____ _____ _____ _____ _____ 
|     |  |  |___| __  |  _  |   __|     |     |
| | | |_   _|___| __ -|     |__   |-   -|   --|
|_|_|_| |_|     |_____|__|__|_____|_____|_____|

Copyright (C) 2011 - 2021 Tony Wang

Build status MIT license

Web playground

Contents

Introduction

MY-BASIC is a lightweight BASIC interpreter written in standard C in dual files. It aims to be embeddable, extendable and portable. It is a dynamic typed programming language, reserves structured syntax, supports a style of prototype-based programming (OOP), also implements a functional paradigm by lambda abstraction. The core is written in a C source file and an associated header file. It's easy to either use it as a standalone interpreter or embed it with existing projects in C, C++, Java, Objective-C, Swift, C#, etc. and totally customizable by adding your own scripting interface.

Main features

MY-BASIC offers a wide range of features including:

  • Written in standard C, source code is portable to a dozen of platforms
  • Lightweight (within less than 128KB footprint), fast, and configurable
  • With both retro and modern BASIC syntax
  • Case-insensitive tokenization, and many other indelible BASIC flavour
  • Unicode support
  • Prototype-based programming, with reflection support
  • Lambda abstraction enhanced functional programming
  • Customizable referenced/non-referenced usertype
  • Collection construction and manipulation functions for LIST and DICT
  • Automatic releasing for referenced values (prototype, lambda, referenced usertype, list, dictionary, etc.) benefited from reference counting and garbage collection
  • Common numeric and string functions
  • Structured sub routine definition with the DEF/ENDDEF statements
  • Structured IF/THEN/ELSEIF/ELSE/ENDIF
  • Structured FOR/TO/STEP/NEXT, FOR/IN/NEXT, WHILE/WEND, DO/UNTIL
  • Reserved retro GOTO, GOSUB/RETURN
  • Importing multiple source files with the IMPORT statement
  • Debug API
  • Customizable memory pool
  • Easy API, for extending new BASIC functions
  • Easy interacting BASIC facilities at native side, and vice versa
  • More features under development

BASIC8

Get BASIC8 - the fantasy computer powered by MY-BASIC - on Steam for game and other program development in an integrated environment.

See awesome user creations.

BASIC at a glance

A "Hello World" convention in MY-BASIC:

input "What is your name: ", n$

def greeting(a, b)
	return a + " " + b + " by " + n$ + "."
enddef

print greeting("Hello", "world");

Read the MY-BASIC Quick Reference to get details about how to program in MY-BASIC.

Installation

Using standalone interpreter binary

This repository contains precompiled binaries for Windows and macOS, the easiest way is to download to get a direct playground. Or you can make a build by:

  • Using the Visual Studio solution my_basic.sln for Windows build
  • Using the Xcode workspace my_basic_mac.xcodeproj for macOS build
  • Using the makefile for *nix build

Follow these steps to compile an interpreter binary manually for other platform:

  1. Retrieve everything under the core and shell folders for a minimum setup
  2. Setup your toolchain for compiling and linking
  3. Compile core/my_basic.c and shell/main.c, while both includes core/my_basic.h; then link up an executable

The standalone interpreter supports three running modes:

  • Execute the binary without arguments to use the interactive mode
    • Type "HELP" and hint Enter to see usages
  • Pass a file to the binary to load and run that BASIC source code
  • Pass an argument -e followed with an expression to evaluate and print instantly as a simple calculator, eg. -e "22 / 7"

Combining with existing projects

Just copy core/my_basic.c and core/my_basic.h to your project and add them to the build pipeline. You can link with MY-BASIC as a lib as well.

For details about using MY-BASIC after integration, see MY-BASIC Quick Reference and read the Wiki pages.

Interpreter workflow diagram

MY-BASIC's workflow diagram can be concluded in a single image.

A simple setup:

#include "my_basic.h"

int main() {
	struct mb_interpreter_t* bas = NULL;

	mb_init();
	mb_open(&bas);
	mb_load_string(bas, "print 22 / 7;", true);
	mb_run(bas, true);
	mb_close(&bas);
	mb_dispose();

	return 0;
}

Wiki

The manual explains most of the fundamental topics, however it doesn't cover everything; read the Wiki for supplements, like machinism behind MY-BASIC, efficient practice, etc:

Donate

List of donors.

Consider supporting MY-BASIC development with a donation if you like this project.

One-off donation via PayPal.

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