Skip to content
This repository has been archived by the owner on Sep 24, 2022. It is now read-only.

StoryScriptorg/StoryScript

Repository files navigation

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<int> a = new Type<int>()

// 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<return type>
// For example:
Action<int> anonymousFunction = (int a, int b) => return a + b
Action<void> 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:

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:

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.