StoryScript is a (mainly) interpreted language

StoryScriptorg, updated 🕥 2022-09-24 09:25:55

StoryScript

StoryScript Logo

Issues Forks Stars License Quality Gate Status Join the chat at https://gitter.im/StoryScripting/community codecov Maintainability DeepSource Discord

StoryScript is an interpreted programming language that is made to being easy to learn.

How to install

You can install StoryScript from PyPi using pip

pip install storyscript # Install storyscript pip install --upgrade storyscript # Update storyscript if you already have it

Repository archival

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.

Syntax I have planned so far

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 a = new 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 // For example: Action anonymousFunction = (int a, int b) => return a + b Action anotherAnonymousFunction = () => { // multiline anonymous function print("weeeeeeee") }

// 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
}

} ```

Code style in StoryScript

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

Download lastest code from main

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

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)

Usage

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

How to use the Language

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.

Issues

Functions?

opened on 2021-10-20 22:04:37 by ghost

Just noticed that there are no functions. I'd like to help with Story Script, and work on its features

Multiline Statement supports

opened on 2021-07-15 05:40:35 by lines-of-codes
  • [ ] Change from Looping through each line to iterators instead OR make a Code concatenator
  • [ ] Migrate loopfor loop to the New system
  • [ ] Multiline comments
  • [ ] Migrate If statement to the New system
  • [ ] [Shell] Add Multiline expression support

Releases

0.0.2 Alpha - The quality release 2021-08-23 01:34:04

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

Lambda expression example: py Action add = lambda int (int a, int b) => a + b Lambda expression syntax: py lambda returnType (arguments) => expression

StoryScript Lite

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!

Downloading the REPL

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

StoryScript Alpha 1 (0.0.1a) 2021-07-07 14:23:33

These are StoryScript features added in version alpha 1:

  • Basic Math operations
    • Add
    • Subtract
    • Multiplication
    • Division
    • Powering
    • Remainders (Modulo)
  • If statement
  • Variables (with Type checking)
  • Ternary operator
  • Switch case statement

Note that multiple lines statements are not supported yet.

StoryScriptorg
GitHub Repository

python programming-language interpreter