MBrosik / ShortScript

Custom interpreted language focused on minimal syntax

Home Page:https://shortscript.spookyless.net/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ShortScript

Custom interpreted language focused on minimal syntax

Language features

  • interpreted
  • statically typed
  • supports most common arithmetic and logic operations
  • functions and QoL loops
  • object-oriented
  • inheritance
  • minimal syntax

Grammar

ShortScript.g4 contains the whole grammar of the language.

Technologies used

IDE Features

image

  • Toolbar with following options:
    • Run code - allows you to run your code
    • Auto run - automatically runs the code if you're not typing
    • Dropdown list allows you select sample programs
  • Syntax highlighting for ShortScript
  • Error highlighting when running the code

Example

More examples, for both grammar and working programs, can be found in examples directory

Input

n f fib(n num){
  if(num <= 0){
    r 0
  }
  
  if(num == 1){
    r 1
  }

  r fib(num - 1) + fib(num - 2) 
}
  
print('Result: ' + fib(8))

Output

Result: 21

Parse tree

image

Running ShortScript IDE

Prerequisites

To build and run the interpreter, you need to have antlr4 installed on your system and present on PATH. It is advised to follow the official documentation.

For additional features (such us grammar testing), you also need to install antlr4-tools, using the official documentation.

Application requires NodeJS >=20.9.0 to run smoothly. Running ShortScript on other versions of Node might lead to errors.

Setup and building sources

  1. Clone the repository
git clone https://github.com/Spookyless/ShortScript.git
cd ShortScript
  1. Install dependencies
npm install

Running the application

  1. Start the development server
npm run dev
  1. ...or, build the application and start the production version:
npm build
npm start

New tab in your default browser should open (usually on localhost:3000). When development server is ready, you'll have a full access to ShortScript IDE.

Testing

All tests suites can be launched using a single script:

npm test

If you want more granular control over what tests are run, you can execute specified stages (found in package.json):

npm run test:grammar

Test cases are located inside examples/grammar directory.

Authors

License

ShortScript is licensed under MIT License, more information can be found in the LICENSE.md file

About

Custom interpreted language focused on minimal syntax

https://shortscript.spookyless.net/

License:MIT License


Languages

Language:TypeScript 73.1%Language:ANTLR 15.2%Language:CSS 9.2%Language:HTML 1.3%Language:Dockerfile 1.1%