*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
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
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)
[![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)
@ -24,7 +24,7 @@
## 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
@ -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:
* Using the Visual Studio workspace `my_basic.sln` on Windows to build an executable
* Using the Xcode workspace `my_basic_mac.xcodeproj` on macOS to build an executable
* Using the `makefile` on *nix OS to build an executable
* 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 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
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:
* 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 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
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.
## [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)
A simple setup as follow:
A simple setup:
~~~~~~~~~~c
#include "my_basic.h"
@ -130,7 +130,7 @@ int main() {
## [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
* [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/
**
** 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
** 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/
**
** 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
** this software and associated documentation files (the "Software"), to deal in

View File

@ -1,36 +1,46 @@
<!DOCTYPE html>
<!--
COPYRIGHT 2011 - 2020 WANG RENXIN. ALL RIGHTS REESERVED.
COPYRIGHT 2011 - 2021 TONY WANG. ALL RIGHTS REESERVED.
LIST OF DONORS.
-->
<html>
<head>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Donate to MY-BASIC</title>
<style type="text/css">
body {
margin: 0; padding: 0;
margin: 0;
padding: 0;
background-color: #789;
font: 14px Helvetica, Arial, sans-serif;
}
div.content {
width: 600px; margin: 2em auto; padding: 20px 50px;
border-radius: 1em;
width: 600px;
margin: 2em auto;
border-radius: 4px;
padding: 20px 50px;
background-color: #fff;
}
a:link, a:visited { color: #69c; text-decoration: none; }
a:link,
a:visited {
color: #69c;
text-decoration: none;
}
@media (max-width: 700px) {
body { background-color: #fff; }
body {
background-color: #fff;
}
div.content {
width: auto; margin: 0 auto; padding: 1em;
width: auto;
margin: 0 auto;
border-radius: 0;
padding: 1em;
}
}
</style>
</head>
<body>
</head>
<body>
<div class="content">
<p>
<a href="https://github.com/paladin-t/my_basic">BACK TO MY-BASIC</a>
@ -45,6 +55,7 @@ LIST OF DONORS.
</p>
<p>
<ul type="none">
<li>Carlin Wiegner</li>
<li>Ken Seergobin</li>
<li>Francesco De Simone</li>
<li>Nicola Giacobbe</li>
@ -71,7 +82,11 @@ LIST OF DONORS.
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="M9S3PACSX8RLW">
<table>
<tr><td><input type="hidden" name="on0" value="Donate with">Donate with</td></tr><tr><td><select name="os0">
<tr>
<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>
@ -79,10 +94,12 @@ LIST OF DONORS.
<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>
</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!">
<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 />
@ -94,27 +111,29 @@ LIST OF DONORS.
<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.
No 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.
PayPal accepts direct transaction with regular credit cards and debit cards.
</p>
<h3>
Q: How should I choose a different amount?
Q: How can 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.
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>
<p>
<a href="https://github.com/paladin-t/my_basic">BACK TO MY-BASIC</a>
</p>
<hr />
<p align="center">Copyright (C) 2011 - 2021 Tony Wang, all rights reserved</p>
</div>
<p align="center">Copyright (C) 2011 - 2020 Wang Renxin. All rights reserved.</p>
</body>
</body>
</html>

View File

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

View File

@ -2,8 +2,8 @@
**my_basic.exe**
Compiled with "Visual C++ 2015", as x86 executable.
Compiled with Visual C++ 2015, as x86 executable.
**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"
BEGIN
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 "FileVersion", "1, 2, 0, 0"
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 "OriginalFilename", "my_basic.exe"
VALUE "ProductName", "MY-BASIC"

View File

@ -3,7 +3,7 @@
**
** 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
** 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) {
_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("Input HELP and hint enter to view help information.\n");
}
@ -999,19 +999,19 @@ static void _show_help(void) {
_printf("\n");
_printf("Interactive commands:\n");
_printf(" HELP - View help information\n");
_printf(" CLS - Clear screen\n");
_printf(" NEW - Clear current program\n");
_printf(" RUN - Run current program\n");
_printf(" BYE - Quit interpreter\n");
_printf(" LIST - List current program\n");
_printf(" CLS - Clear the screen\n");
_printf(" NEW - Clear the current program\n");
_printf(" RUN - Run the current program\n");
_printf(" BYE - Quit the interpreter\n");
_printf(" LIST - List the current program\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(" Usage: EDIT n, n is line number\n");
_printf(" EDIT -i n, insert a line before a given 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(" SAVE - Save current program to a file\n");
_printf(" SAVE - Save the current program to a file\n");
_printf(" Usage: SAVE *.*\n");
_printf(" KILL - Delete a file\n");
_printf(" Usage: KILL *.*\n");