StoryScript is an interpreted programming language that is made to being easy to learn.
You can install StoryScript from PyPi using pip
pip install storyscript # Install storyscript
pip install --upgrade storyscript # Update storyscript if you already have it
I'm archiving this repository soon due to the fact I don't have the interest in developing this project further in Python. Maybe I'll comeback in the future with this project but written in another programming language? or maybe that day would never come?
If anyone wants to continue this project, I'd recommend that you don't fork this repository as the structure is hell. but I won't stop you from doing so.
This will include the syntax I've planned, both implemented and not implemented. so you could use this as a reference for StoryScript's syntax if you're gonna recreate StoryScript.
``` // Comments / Multiline comments /
// Variables Type a Type a = null
// creating a new instance of a class
Type a = new type()
Type
// Imports import Something from "./something.sts" import FromPackage from "PackageName"
// An anonymous function
// When storing an anonymous function in a variable, the type of the variable should be Action
// Functions void function(string name) { print("Hello, " + name) }
// Classes class A { int field public int property { get; private set }
// constructor
void A() {
print("weeeee")
}
abstract void methodA()
void methodB() {
print("hello world")
}
}
// structs struct Struct { // correct int fieldA
// invalid
int fieldB = 69420
// constructor
void Struct() {
fieldA = 69420
}
} ```
Classes and Structs should be in PascalCase
Variables and Functions should be in camelCase
Built-in types (including: int, float, dynamic, string) should also be in camelCase
You can just download or git clone
the source code from Main branch. (And wish there is no bug)
Firstly, remember that you need Python installed.
I recommended at least Python 3.8 to make sure it is working.
Due to Pull request #27, You can now easily setup StoryScript by doing:
bash
python setup.py install
Note: If you are looking for C Transpiler source, It has been moved here
Required packages: - Numpy - Colorama
These are required packages for StoryScript, You can setup them manually or install through the setup script.
Optional: - PyInstrument (Used for benchmarking)
You can either python -m storyscript
, or storyscript
(if the Python program installation is on your PATH), Then it will launch the shell, And you can use the language.
All the examples listed below should work with both methods.
And to execute a file, Use storyscript -i [filename]
and replace [filename]
with the real file name. For example:
text
storyscript -i main.sts
Please visit the Wiki for more info about how to use StoryScript.
Or if you would rather want a tutorial, you could try the free StoryScript course.
Just noticed that there are no functions. I'd like to help with Story Script, and work on its features
This release contains multiple quality improvements and various bug fixes.
Here's the changelog for this release.
- Added Original text-based parsing for more precision parsing. (Only for some methods)
- Added variable detection in math parser.
- Added arrays
- Added lambda expression
- Move static unchanged constants outside of the analyse_command method
- [Styling] Rename multiple methods to snake_case
- Make typeof
function return a string instead of Types enum
- Added type conversion methods
- int.FromString - Converts a string to int
- int.FromFloat - Converts float to int
- int.IsFloatFullNumber - Check If a float is a full number (example: 3.0 = true
, 3.14 = false
)
- integerVariable.ToString - Converts an integer variable to String
- string.FromInt/string.FromFloat - converts Integer/Float to String.
- Added type "Action" for a lambda expression
- Lambda expression
- Added new exception, "InvalidOperatorException" (ID: 109)
- Move SymbolTable class to SymbolTable.py
- Added bitwise operators (NOT, OR, AND, XOR, bitwise left shift, bitwise right shift)
- Added direct boolean comparison support in if statement
- Space safe function calls (now, print(
and print (
will be both valid, this applies to all functions)
- Move escape character parsing to math parser, (and this added support for escaping quotes too)
- You can now execute files through the shell executable
Lambda expression example:
py
Action add = lambda int (int a, int b) => a + b
Lambda expression syntax:
py
lambda returnType (arguments) => expression
StoryScript lite is a minified version of StoryScript - Note that this shouldn't be used for development/debugging build. As most debugging features are removed.
~~You can download StoryScript lite by downloading the storyscript_lite.zip
file. And extract it.~~ Not available for download yet, But will soon!
To get the REPL, Download StoryScript-v0.0.2-Shell.zip
, and then extract it, and you can run the shell.exe
easily to get the REPL running.
Example of executing a file:
shell.exe -i main.sts
These are StoryScript features added in version alpha 1:
Note that multiple lines statements are not supported yet.
python programming-language interpreter