{"id":13438531,"url":"https://github.com/paladin-t/my_basic","last_synced_at":"2025-04-05T00:10:43.931Z","repository":{"id":14175735,"uuid":"16881875","full_name":"paladin-t/my_basic","owner":"paladin-t","description":"A lightweight BASIC interpreter written in standard C in dual files. Aims to be embeddable, extendable and portable.","archived":false,"fork":false,"pushed_at":"2024-05-01T03:26:48.000Z","size":37441,"stargazers_count":490,"open_issues_count":28,"forks_count":116,"subscribers_count":52,"default_branch":"master","last_synced_at":"2024-05-20T23:28:27.100Z","etag":null,"topics":["basic","interpreter","programming-language","scripting-language"],"latest_commit_sha":null,"homepage":"http://paladin-t.github.io/my_basic/","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/paladin-t.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-02-16T09:24:50.000Z","updated_at":"2024-07-05T18:25:19.192Z","dependencies_parsed_at":"2024-07-05T18:40:35.547Z","dependency_job_id":null,"html_url":"https://github.com/paladin-t/my_basic","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paladin-t%2Fmy_basic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paladin-t%2Fmy_basic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paladin-t%2Fmy_basic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paladin-t%2Fmy_basic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paladin-t","download_url":"https://codeload.github.com/paladin-t/my_basic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247266565,"owners_count":20910836,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["basic","interpreter","programming-language","scripting-language"],"created_at":"2024-07-31T03:01:06.264Z","updated_at":"2025-04-05T00:10:43.911Z","avatar_url":"https://github.com/paladin-t.png","language":"C","readme":"~~~~~~~~~~\r\n _____ __ __     _____ _____ _____ _____ _____ \r\n|     |  |  |___| __  |  _  |   __|     |     |\r\n| | | |_   _|___| __ -|     |__   |-   -|   --|\r\n|_|_|_| |_|     |_____|__|__|_____|_____|_____|\r\n~~~~~~~~~~\r\n\r\n**Copyright (C) 2011 - 2024 Tony Wang**\r\n\r\n[![Build status](https://github.com/paladin-t/my_basic/actions/workflows/c.yml/badge.svg)](https://github.com/paladin-t/my_basic/actions/workflows/c.yml)\r\n[![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)\r\n\r\n[Web playground](https://my-basic.github.io/playground/output/index.html)\r\n\r\n## Contents\r\n\r\n* [Introduction](#introduction)\r\n* [Main features](#main-features)\r\n* [BASIC at a glance](#basic-at-a-glance)\r\n* [Installation](#installation)\r\n* [Interpreter workflow diagram](#interpreter-workflow-diagram)\r\n* [Wiki](#wiki)\r\n* [Donate](#donate)\r\n\r\n## Introduction\r\n\r\nMY-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](https://en.wikipedia.org/wiki/Prototype-based_programming) (OOP), also implements a functional paradigm by [lambda abstraction](https://en.wikipedia.org/wiki/Anonymous_function). 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.\r\n\r\n## Main features\r\n\r\nMY-BASIC offers a wide range of features including:\r\n\r\n* Written in standard C, source code is portable to a dozen of platforms\r\n* Lightweight (within less than 128KB footprint), fast, and configurable\r\n* With both retro and modern BASIC syntax\r\n* Case-insensitive tokenization, and many other indelible BASIC flavour\r\n* [Unicode support](https://github.com/paladin-t/my_basic/wiki/Using-Unicode)\r\n* [Prototype-based programming](https://en.wikipedia.org/wiki/Prototype-based_programming), with reflection support\r\n* [Lambda abstraction](https://en.wikipedia.org/wiki/Anonymous_function) enhanced functional programming\r\n* Customizable referenced/non-referenced usertype\r\n* Collection construction and manipulation functions for `LIST` and `DICT`\r\n* Automatic releasing for referenced values (prototype, lambda, referenced usertype, list, dictionary, etc.) benefited from reference counting and garbage collection\r\n* Common numeric and string functions\r\n* Structured sub routine definition with the `DEF/ENDDEF` statements\r\n* Structured `IF/THEN/ELSEIF/ELSE/ENDIF`\r\n* Structured `FOR/TO/STEP/NEXT`, `FOR/IN/NEXT`, `WHILE/WEND`, `DO/UNTIL`\r\n* Reserved retro `GOTO`, `GOSUB/RETURN`\r\n* Importing multiple source files with the `IMPORT` statement\r\n* Debug API\r\n* Customizable memory pool\r\n* Easy API, for extending new BASIC functions\r\n* Easy interacting BASIC facilities at native side, and vice versa\r\n* More features under development\r\n\r\n[![BASIC8](https://github.com/paladin-t/my_basic/wiki/img/basic8_banner.png)](https://paladin-t.github.io/b8/)\r\n\r\nGet [BASIC8](https://paladin-t.github.io/b8/) - the **Fantasy Computer** powered by MY-BASIC - on [Steam](http://store.steampowered.com/app/767240/) for game and other program development in an integrated environment.\r\n\r\nSee awesome [user creations](https://my-basic.github.io/awesome/).\r\n\r\n## BASIC at a glance\r\n\r\nA \"Hello World\" convention in MY-BASIC:\r\n\r\n~~~~~~~~~~bas\r\ninput \"What is your name: \", n$\r\n\r\ndef greeting(a, b)\r\n\treturn a + \" \" + b + \" by \" + n$ + \".\"\r\nenddef\r\n\r\nprint greeting(\"Hello\", \"world\");\r\n~~~~~~~~~~\r\n\r\nRead the [MY-BASIC Quick Reference](https://paladin-t.github.io/my_basic/MY-BASIC%20Quick%20Reference.pdf) to get details about how to program in MY-BASIC.\r\n\r\n## Installation\r\n\r\n### Using standalone interpreter binary\r\n\r\nThis repository contains precompiled binaries for [Windows](output/my_basic.exe), [macOS](output/my_basic_mac) and [Linux](output/my_basic_linux), the easiest way is to download to get a direct playground. Or you can make a build by:\r\n\r\n* Using the Visual Studio solution `my_basic.sln` for Windows build\r\n* Using the Xcode workspace `my_basic_mac.xcodeproj` for macOS build\r\n* Using the `makefile` for Linux build\r\n\r\nFollow these steps to compile an interpreter binary manually for other platform:\r\n\r\n1. Retrieve everything under the [`core`](core) and [`shell`](shell) folders for a minimum setup\r\n2. Setup your toolchain for compiling and linking\r\n3. Compile [`core/my_basic.c`](core/my_basic.c) and [`shell/main.c`](shell/main.c), while both includes [`core/my_basic.h`](core/my_basic.h); then link up an executable\r\n\r\nThe standalone interpreter supports three running modes:\r\n\r\n* Execute the binary without arguments to use the interactive mode\r\n\t* Type \"HELP\" and hint Enter to see usages\r\n* Pass a file to the binary to load and run that BASIC source code\r\n* Pass an argument `-e` followed with an expression to evaluate and print instantly as a simple calculator, eg. `-e \"22 / 7\"`\r\n\r\n### Combining with existing projects\r\n\r\nJust copy [`core/my_basic.c`](core/my_basic.c) and [`core/my_basic.h`](core/my_basic.h) to your project and add them to the build pipeline. You can [link with MY-BASIC as a lib](https://github.com/paladin-t/my_basic/wiki/Linking-with-MY_BASIC) as well.\r\n\r\nFor details about using MY-BASIC after integration, see [MY-BASIC Quick Reference](https://paladin-t.github.io/my_basic/MY-BASIC%20Quick%20Reference.pdf) and read the [Wiki](#wiki) pages.\r\n\r\n## [Interpreter workflow diagram](https://github.com/paladin-t/my_basic/wiki/Interpreter-workflow-diagram)\r\n\r\nMY-BASIC's workflow diagram can be concluded in a single image.\r\n\r\n![](https://github.com/paladin-t/my_basic/wiki/img/workflow.png)\r\n\r\nA simple setup:\r\n\r\n~~~~~~~~~~c\r\n#include \"my_basic.h\"\r\n\r\nint main() {\r\n\tstruct mb_interpreter_t* bas = NULL;\r\n\r\n\tmb_init();\r\n\tmb_open(\u0026bas);\r\n\tmb_load_string(bas, \"print 22 / 7;\", true);\r\n\tmb_run(bas, true);\r\n\tmb_close(\u0026bas);\r\n\tmb_dispose();\r\n\r\n\treturn 0;\r\n}\r\n~~~~~~~~~~\r\n\r\n## [Wiki](https://github.com/paladin-t/my_basic/wiki)\r\n\r\nThe manual explains most of the fundamental topics, however it doesn't cover everything; read the [Wiki](https://github.com/paladin-t/my_basic/wiki) for supplements, like machinism behind MY-BASIC, efficient practice, etc:\r\n\r\n* Principles\r\n\t* [Passes](https://github.com/paladin-t/my_basic/wiki/Passes)\r\n\t* [Interpreter workflow diagram](https://github.com/paladin-t/my_basic/wiki/Interpreter-workflow-diagram)\r\n\t* [How lambda works](https://github.com/paladin-t/my_basic/wiki/How-lambda-works)\r\n* Coding\r\n\t* [Using Unicode](https://github.com/paladin-t/my_basic/wiki/Using-Unicode)\r\n\t* [Importing another file](https://github.com/paladin-t/my_basic/wiki/Importing-another-file)\r\n\t* [Module (namespace)](https://github.com/paladin-t/my_basic/wiki/Module-(namespace))\r\n\t* [Sub routine](https://github.com/paladin-t/my_basic/wiki/Sub-routine)\r\n\t* [Lambda abstraction](https://github.com/paladin-t/my_basic/wiki/Lambda-abstraction)\r\n\t* [Structured exception handling](https://github.com/paladin-t/my_basic/wiki/Structured-exception-handling)\r\n\t* [Multiple condition](https://github.com/paladin-t/my_basic/wiki/Multiple-condition)\r\n* Data types\r\n\t* [Collection manipulation](https://github.com/paladin-t/my_basic/wiki/Collection-manipulation)\r\n\t* [Manipulating an array](https://github.com/paladin-t/my_basic/wiki/Manipulating-an-array)\r\n\t* [Automatic memory management](https://github.com/paladin-t/my_basic/wiki/Automatic-memory-management)\r\n\t* [Using usertype values](https://github.com/paladin-t/my_basic/wiki/Using-usertype-values)\r\n\t* [Using prototype-based class](https://github.com/paladin-t/my_basic/wiki/Using-prototype-based-class)\r\n\t* [Defining a class in C](https://github.com/paladin-t/my_basic/wiki/Defining-a-class-in-C)\r\n\t* [Meta methods](https://github.com/paladin-t/my_basic/wiki/Meta-methods)\r\n\t* [Overriding operators](https://github.com/paladin-t/my_basic/wiki/Overriding-operators)\r\n\t* [Overriding functions](https://github.com/paladin-t/my_basic/wiki/Overriding-functions)\r\n\t* [Using iterators](https://github.com/paladin-t/my_basic/wiki/Using-iterators)\r\n* Standalone shell\r\n\t* [Extra functions](https://github.com/paladin-t/my_basic/wiki/Extra-functions)\r\n* Integration\r\n\t* [Linking with MY-BASIC](https://github.com/paladin-t/my_basic/wiki/Linking-with-MY_BASIC)\r\n\t* [Writing a debugger](https://github.com/paladin-t/my_basic/wiki/Writing-a-debugger)\r\n\t* [Callback](https://github.com/paladin-t/my_basic/wiki/Callback)\r\n\t* [Interop with C#](https://github.com/paladin-t/my_basic/wiki/Interop-with-C%23)\r\n* Customization\r\n\t* [Customizing macros](https://github.com/paladin-t/my_basic/wiki/Customizing-macros)\r\n\t* [Customizing a memory allocator](https://github.com/paladin-t/my_basic/wiki/Customizing-a-memory-allocator)\r\n\t* [Redirecting PRINT and INPUT](https://github.com/paladin-t/my_basic/wiki/Redirecting-PRINT-and-INPUT)\r\n\t* [Redefining int_t and real_t](https://github.com/paladin-t/my_basic/wiki/Redefining-int_t-and-real_t)\r\n\t* [Converting between string and real](https://github.com/paladin-t/my_basic/wiki/Converting-between-string-and-real)\r\n\t* [Customizing an importer](https://github.com/paladin-t/my_basic/wiki/Customizing-an-importer)\r\n* More scripting API\r\n\t* [String matching module](https://github.com/paladin-t/my_basic/wiki/String-matching-module)\r\n\t* [String manipulation module](https://github.com/paladin-t/my_basic/wiki/String-manipulation-module)\r\n\t* [File module](https://github.com/paladin-t/my_basic/wiki/File-module)\r\n\t* [Inline data sequence module](https://github.com/paladin-t/my_basic/wiki/Inline-data-sequence-module)\r\n\t* [Bit operation module](https://github.com/paladin-t/my_basic/wiki/Bit-operation-module)\r\n\t* [Miscellaneous module](https://github.com/paladin-t/my_basic/wiki/Miscellaneous-module)\r\n\t* [Stack module](https://github.com/paladin-t/my_basic/wiki/Stack-module)\r\n* [FAQ](https://github.com/paladin-t/my_basic/wiki/FAQ)\r\n\t* [Is it possible to introduce another feature](https://github.com/paladin-t/my_basic/wiki/Is-it-possible-to-introduce-another-feature)\r\n\r\n## Donate\r\n\r\n[List of donors](http://paladin-t.github.io/my_basic/donate.html).\r\n\r\nConsider supporting MY-BASIC development with a donation if you like this project.\r\n\r\nOne-off [donation](http://paladin-t.github.io/my_basic/donate.html) via PayPal.\r\n\r\n\u003ca href=\"http://paladin-t.github.io/my_basic/donate.html\"\u003e\r\n\u003cimg src=\"https://github.com/paladin-t/my_basic/wiki/img/button_donate.png\" width=\"92\"\u003e\r\n\u003c/a\u003e\r\n","funding_links":[],"categories":["C","Dialects","Compilers and Interpreters"],"sub_categories":["Educational and Toy Projects"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaladin-t%2Fmy_basic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaladin-t%2Fmy_basic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaladin-t%2Fmy_basic/lists"}