*welcome 2021. *updated the reference document.

This commit is contained in:
Wang Renxin 2021-01-22 16:24:42 +08:00
parent e7a6307b81
commit 281a292d94
12 changed files with 158 additions and 139 deletions

View File

@ -1,6 +1,6 @@
The MIT License The MIT License
Copyright (C) 2011 - 2020 Wang Renxin Copyright (C) 2011 - 2021 Tony Wang
Permission is hereby granted, free of charge, to any person obtaining a copy of 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 this software and associated documentation files (the "Software"), to deal in

Binary file not shown.

View File

@ -5,7 +5,7 @@
|_|_|_| |_| |_____|__|__|_____|_____|_____| |_|_|_| |_| |_____|__|__|_____|_____|_____|
~~~~~~~~~~ ~~~~~~~~~~
**Copyright (C) 2011 - 2020 Wang Renxin** **Copyright (C) 2011 - 2021 Tony Wang**
[![Build status](https://travis-ci.org/paladin-t/my_basic.svg?branch=master)](https://travis-ci.org/paladin-t/my_basic) [![Build status](https://travis-ci.org/paladin-t/my_basic.svg?branch=master)](https://travis-ci.org/paladin-t/my_basic)
[![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT) [![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)
@ -24,7 +24,7 @@
## Introduction ## Introduction
MY-BASIC is a lightweight BASIC interpreter written in standard C in dual files. It's aimed 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 interfaces. 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](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.
## Main features ## Main features
@ -80,36 +80,36 @@ Read the [MY-BASIC Quick Reference](https://paladin-t.github.io/my_basic/MY-BASI
This repository contains precompiled binaries for [Windows](output/my_basic.exe) and [macOS](output/my_basic_mac), the easiest way is to download to get a direct playground. Or you can make a build by: This repository contains precompiled binaries for [Windows](output/my_basic.exe) and [macOS](output/my_basic_mac), the easiest way is to download to get a direct playground. Or you can make a build by:
* Using the Visual Studio workspace `my_basic.sln` on Windows to build an executable * Using the Visual Studio solution `my_basic.sln` for Windows build
* Using the Xcode workspace `my_basic_mac.xcodeproj` on macOS to build an executable * Using the Xcode workspace `my_basic_mac.xcodeproj` for macOS build
* Using the `makefile` on *nix OS to build an executable * Using the `makefile` for *nix build
Follow these steps to compile an interpreter binary manually for any platform: Follow these steps to compile an interpreter binary manually for other platform:
1. Retrieve everything under the [`core`](core) and [`shell`](shell) folders for a minimum build 1. Retrieve everything under the [`core`](core) and [`shell`](shell) folders for a minimum setup
2. Setup your toolchain for compiling and linking 2. Setup your toolchain for compiling and linking
3. Compile [`core/my_basic.c`](core/my_basic.c) and [`shell/main.c`](shell/main.c), with both including [`core/my_basic.h`](core/my_basic.h); then link up an executable 3. 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
The standalone interpreter supports three running modes: The standalone interpreter supports three running modes:
* Execute the binary without arguments to use the interactive mode * Execute the binary without arguments to use the interactive mode
* Type "HELP" and hint Enter to get usages of it * Type "HELP" and hint Enter to see usages
* Pass a file to the binary to load and run that BASIC source code * 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 "2 * (3 + 4)"` * 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 ### Combining with existing projects
Just 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 configuration. You can [link with MY-BASIC as a lib](https://github.com/paladin-t/my_basic/wiki/Linking-with-MY_BASIC) as well. Just 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.
For 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. For 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.
## [Interpreter workflow diagram](https://github.com/paladin-t/my_basic/wiki/Interpreter-workflow-diagram) ## [Interpreter workflow diagram](https://github.com/paladin-t/my_basic/wiki/Interpreter-workflow-diagram)
It's recommended to know the basic principle of MY-BASIC before customizing; nothing's better than a workflow diagram to get a first image. MY-BASIC's workflow diagram can be concluded in a single image.
![](https://github.com/paladin-t/my_basic/wiki/img/workflow.png) ![](https://github.com/paladin-t/my_basic/wiki/img/workflow.png)
A simple setup as follow: A simple setup:
~~~~~~~~~~c ~~~~~~~~~~c
#include "my_basic.h" #include "my_basic.h"
@ -130,7 +130,7 @@ int main() {
## [Wiki](https://github.com/paladin-t/my_basic/wiki) ## [Wiki](https://github.com/paladin-t/my_basic/wiki)
The manual explains most of the fundamental topics, however it doesn't cover everything; read the [Wiki](https://github.com/paladin-t/my_basic/wiki) as supplement instructions, such as machinism behind MY-BASIC, efficient practice, etc: The 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:
* Principles * Principles
* [Passes](https://github.com/paladin-t/my_basic/wiki/Passes) * [Passes](https://github.com/paladin-t/my_basic/wiki/Passes)

View File

@ -3,7 +3,7 @@
** **
** For the latest info, see https://github.com/paladin-t/my_basic/ ** For the latest info, see https://github.com/paladin-t/my_basic/
** **
** Copyright (C) 2011 - 2020 Wang Renxin ** Copyright (C) 2011 - 2021 Tony Wang
** **
** Permission is hereby granted, free of charge, to any person obtaining a copy of ** 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 ** this software and associated documentation files (the "Software"), to deal in

View File

@ -3,7 +3,7 @@
** **
** For the latest info, see https://github.com/paladin-t/my_basic/ ** For the latest info, see https://github.com/paladin-t/my_basic/
** **
** Copyright (C) 2011 - 2020 Wang Renxin ** Copyright (C) 2011 - 2021 Tony Wang
** **
** Permission is hereby granted, free of charge, to any person obtaining a copy of ** 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 ** this software and associated documentation files (the "Software"), to deal in

View File

@ -1,120 +1,139 @@
<!DOCTYPE html> <!DOCTYPE html>
<!-- <!--
COPYRIGHT 2011 - 2020 WANG RENXIN. ALL RIGHTS REESERVED. COPYRIGHT 2011 - 2021 TONY WANG. ALL RIGHTS REESERVED.
LIST OF DONORS. LIST OF DONORS.
--> -->
<html> <html>
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Donate to MY-BASIC</title> <title>Donate to MY-BASIC</title>
<style type="text/css"> <style type="text/css">
body { body {
margin: 0; padding: 0; margin: 0;
background-color: #789; padding: 0;
font: 14px Helvetica, Arial, sans-serif; background-color: #789;
} font: 14px Helvetica, Arial, sans-serif;
div.content { }
width: 600px; margin: 2em auto; padding: 20px 50px; div.content {
border-radius: 1em; width: 600px;
background-color: #fff; margin: 2em auto;
} border-radius: 4px;
a:link, a:visited { color: #69c; text-decoration: none; } padding: 20px 50px;
@media (max-width: 700px) { background-color: #fff;
body { background-color: #fff; } }
div.content { a:link,
width: auto; margin: 0 auto; padding: 1em; a:visited {
border-radius: 0; color: #69c;
} text-decoration: none;
} }
</style> @media (max-width: 700px) {
</head> body {
background-color: #fff;
}
div.content {
width: auto;
margin: 0 auto;
border-radius: 0;
padding: 1em;
}
}
</style>
</head>
<body>
<div class="content">
<p>
<a href="https://github.com/paladin-t/my_basic">BACK TO MY-BASIC</a>
</p>
<body> <h1>Donate to MY-BASIC</h1>
<div class="content">
<p>
<a href="https://github.com/paladin-t/my_basic">BACK TO MY-BASIC</a>
</p>
<h1>Donate to MY-BASIC</h1> <h2>List of Donors</h2>
<p>
Here is the list of some of the people who have kindly sent donation for MY-BASIC development.
I greatly appreciate all the donation that has been made.
</p>
<p>
<ul type="none">
<li>Carlin Wiegner</li>
<li>Ken Seergobin</li>
<li>Francesco De Simone</li>
<li>Nicola Giacobbe</li>
<li>Devulder Jean-Paul</li>
<li>Alvin Schmitt</li>
</ul>
</p>
<p>
The list is ordered by most recent.
</p>
<p>
Please <a href="mailto:hellotony521@qq.com">send</a> me a message if you think your name should be listed here, or do not want your name to be listed.
</p>
<hr />
<h2>List of Donors</h2> <h2>Donate</h2>
<p> <p>
Here is the list of some of the people who have kindly sent donation for MY-BASIC development. Thank you for choosing MY-BASIC. Your support is my motivation to make MY-BASIC better.
I greatly appreciate all the donation that has been made. It's totally free to use code/binary/document in the MY-BASIC repository for both commercial and noncommercial purpose under the MIT license.
</p> However, you can support MY-BASIC development with a donation.
<p> </p>
<ul type="none">
<li>Ken Seergobin</li>
<li>Francesco De Simone</li>
<li>Nicola Giacobbe</li>
<li>Devulder Jean-Paul</li>
<li>Alvin Schmitt</li>
</ul>
</p>
<p>
The list is ordered by most recent.
</p>
<p>
Please <a href="mailto:hellotony521@qq.com">send</a> me a message if you think your name should be listed here, or do not want your name to be listed.
</p>
<hr />
<h2>Donate</h2> <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<p> <input type="hidden" name="cmd" value="_s-xclick">
Thank you for choosing MY-BASIC. Your support is my motivation to make MY-BASIC better. <input type="hidden" name="hosted_button_id" value="M9S3PACSX8RLW">
It's totally free to use code/binary/document in the MY-BASIC repository for both commercial and noncommercial purpose under the MIT license. <table>
However, you can support MY-BASIC development with a donation. <tr>
</p> <td><input type="hidden" name="on0" value="Donate with">Donate with</td>
</tr>
<tr>
<td><select name="os0">
<option value="a)">a) $ 0.99 USD</option>
<option value="b)">b) $ 1.99 USD</option>
<option value="c)">c) $ 4.99 USD</option>
<option value="d)">d) $ 9.99 USD</option>
<option value="e)">e) $ 19.99 USD</option>
<option value="f)">f) $ 49.99 USD</option>
<option value="g)">g) $ 99.99 USD</option>
</select> </td>
</tr>
</table>
<input type="hidden" name="currency_code" value="USD">
<input type="image" src="https://www.paypalobjects.com/en_GB/i/btn/btn_paynowCC_LG.gif" border="0" name="submit"
alt="PayPal The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/zh_XC/i/scr/pixel.gif" width="1" height="1">
</form>
<hr />
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top"> <h2>Questions</h2>
<input type="hidden" name="cmd" value="_s-xclick"> <h3>
<input type="hidden" name="hosted_button_id" value="M9S3PACSX8RLW"> Q: Why it's a "Pay Now" instead of "Donate" button?
<table> </h3>
<tr><td><input type="hidden" name="on0" value="Donate with">Donate with</td></tr><tr><td><select name="os0"> <p>
<option value="a)">a) $ 0.99 USD</option> A: "Donate" button is no longer usable with an account from my region, according to PayPal's latest policy.
<option value="b)">b) $ 1.99 USD</option> The only option PayPal offered for me is to use this "Pay Now" instead.
<option value="c)">c) $ 4.99 USD</option> No worry, it's similar and secure.
<option value="d)">d) $ 9.99 USD</option> </p>
<option value="e)">e) $ 19.99 USD</option> <h3>
<option value="f)">f) $ 49.99 USD</option> Q: Do I have to sign up before making donation?
<option value="g)">g) $ 99.99 USD</option> </h3>
</select> </td></tr> <p>
</table> A: No signing up is required to donate with PayPal.
<input type="hidden" name="currency_code" value="USD"> PayPal accepts direct transaction with regular credit cards and debit cards.
<input type="image" src="https://www.paypalobjects.com/en_GB/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" alt="PayPal The safer, easier way to pay online!"> </p>
<img alt="" border="0" src="https://www.paypalobjects.com/zh_XC/i/scr/pixel.gif" width="1" height="1"> <h3>
</form> Q: How can I choose a different amount?
<hr /> </h3>
<p>
A: PayPal's "Pay Now" doesn't support customized price by you.
You may choose a base donation and change the quantity for an approximate expected amount, if it's not on the payment option list.
</p>
<h2>Questions</h2> <p>
<h3> <a href="https://github.com/paladin-t/my_basic">BACK TO MY-BASIC</a>
Q: Why it's a "Pay Now" instead of "Donate" button? </p>
</h3>
<p>
A: "Donate" button is no longer usable with an account from my region, according to PayPal's latest policy.
The only option PayPal offered for me is to use this "Pay Now" instead.
Don't worry, it's similar and secure.
</p>
<h3>
Q: Do I have to sign up before making donation?
</h3>
<p>
A: No signing up is required to donate with PayPal.
PayPal accepts direct transaction with common credit cards and debit cards.
</p>
<h3>
Q: How should I choose a different amount?
</h3>
<p>
A: PayPal's "Pay Now" doesn't support customized price by you.
You may choose a base donation number and change the quantity for an approximate expected amount, if it's not on the payment option list.
</p>
<p> <hr />
<a href="https://github.com/paladin-t/my_basic">BACK TO MY-BASIC</a> <p align="center">Copyright (C) 2011 - 2021 Tony Wang, all rights reserved</p>
</p> </div>
</div> </body>
<p align="center">Copyright (C) 2011 - 2020 Wang Renxin. All rights reserved.</p> </html>
</body>
</html>

View File

@ -102,7 +102,7 @@
isa = PBXProject; isa = PBXProject;
attributes = { attributes = {
LastUpgradeCheck = 1000; LastUpgradeCheck = 1000;
ORGANIZATIONNAME = "Wang Renxin"; ORGANIZATIONNAME = "Tony Wang";
TargetAttributes = { TargetAttributes = {
03F4D7291A1D0081009F920C = { 03F4D7291A1D0081009F920C = {
CreatedOnToolsVersion = 6.1; CreatedOnToolsVersion = 6.1;

View File

@ -2,8 +2,8 @@
**my_basic.exe** **my_basic.exe**
Compiled with "Visual C++ 2015", as x86 executable. Compiled with Visual C++ 2015, as x86 executable.
**my_basic_mac** **my_basic_mac**
Compiled with "Xcode 9", as x86-64 executable. Compiled with Xcode 10, as x86-64 executable.

Binary file not shown.

Binary file not shown.

View File

@ -53,11 +53,11 @@
BLOCK "080404b0" BLOCK "080404b0"
BEGIN BEGIN
VALUE "Comments", "For more information, see https://github.com/paladin-t/my_basic/." VALUE "Comments", "For more information, see https://github.com/paladin-t/my_basic/."
VALUE "CompanyName", "Wang Renxin" VALUE "CompanyName", "Tony Wang"
VALUE "FileDescription", "MY-BASIC Interpreter for Windows" VALUE "FileDescription", "MY-BASIC Interpreter for Windows"
VALUE "FileVersion", "1, 2, 0, 0" VALUE "FileVersion", "1, 2, 0, 0"
VALUE "InternalName", "my_basic" VALUE "InternalName", "my_basic"
VALUE "LegalCopyright", "Copyright (C) 2011 - 2020 Wang Renxin" VALUE "LegalCopyright", "Copyright (C) 2011 - 2021 Tony Wang"
VALUE "LegalTrademarks", "MY-BASIC" VALUE "LegalTrademarks", "MY-BASIC"
VALUE "OriginalFilename", "my_basic.exe" VALUE "OriginalFilename", "my_basic.exe"
VALUE "ProductName", "MY-BASIC" VALUE "ProductName", "MY-BASIC"

View File

@ -3,7 +3,7 @@
** **
** For the latest info, see https://github.com/paladin-t/my_basic/ ** For the latest info, see https://github.com/paladin-t/my_basic/
** **
** Copyright (C) 2011 - 2020 Wang Renxin ** Copyright (C) 2011 - 2021 Tony Wang
** **
** Permission is hereby granted, free of charge, to any person obtaining a copy of ** 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 ** this software and associated documentation files (the "Software"), to deal in
@ -979,7 +979,7 @@ static void _list_directory(const char* path) {
static void _show_tip(void) { static void _show_tip(void) {
_printf("MY-BASIC Interpreter Shell - %s\n", mb_ver_string()); _printf("MY-BASIC Interpreter Shell - %s\n", mb_ver_string());
_printf("Copyright (C) 2011 - 2020 Wang Renxin. All Rights Reserved.\n"); _printf("Copyright (C) 2011 - 2021 Tony Wang. All Rights Reserved.\n");
_printf("For more information, see https://github.com/paladin-t/my_basic/.\n"); _printf("For more information, see https://github.com/paladin-t/my_basic/.\n");
_printf("Input HELP and hint enter to view help information.\n"); _printf("Input HELP and hint enter to view help information.\n");
} }
@ -999,19 +999,19 @@ static void _show_help(void) {
_printf("\n"); _printf("\n");
_printf("Interactive commands:\n"); _printf("Interactive commands:\n");
_printf(" HELP - View help information\n"); _printf(" HELP - View help information\n");
_printf(" CLS - Clear screen\n"); _printf(" CLS - Clear the screen\n");
_printf(" NEW - Clear current program\n"); _printf(" NEW - Clear the current program\n");
_printf(" RUN - Run current program\n"); _printf(" RUN - Run the current program\n");
_printf(" BYE - Quit interpreter\n"); _printf(" BYE - Quit the interpreter\n");
_printf(" LIST - List current program\n"); _printf(" LIST - List the current program\n");
_printf(" Usage: LIST [l [n]], l is start line number, n is line count\n"); _printf(" Usage: LIST [l [n]], l is start line number, n is line count\n");
_printf(" EDIT - Edit (modify/insert/remove) a line in current program\n"); _printf(" EDIT - Edit (modify/insert/remove) a line in current program\n");
_printf(" Usage: EDIT n, n is line number\n"); _printf(" Usage: EDIT n, n is line number\n");
_printf(" EDIT -i n, insert a line before a given line\n"); _printf(" EDIT -i n, insert a line before a given line\n");
_printf(" EDIT -r n, remove a line\n"); _printf(" EDIT -r n, remove a line\n");
_printf(" LOAD - Load a file as current program\n"); _printf(" LOAD - Load a file to the current program\n");
_printf(" Usage: LOAD *.*\n"); _printf(" Usage: LOAD *.*\n");
_printf(" SAVE - Save current program to a file\n"); _printf(" SAVE - Save the current program to a file\n");
_printf(" Usage: SAVE *.*\n"); _printf(" Usage: SAVE *.*\n");
_printf(" KILL - Delete a file\n"); _printf(" KILL - Delete a file\n");
_printf(" Usage: KILL *.*\n"); _printf(" Usage: KILL *.*\n");