https://github.com/spookyless/shortscript
Custom interpreted language focused on minimal syntax
https://github.com/spookyless/shortscript
antlr4 interpreted-programming-language interpreter shortscript
Last synced: 8 months ago
JSON representation
Custom interpreted language focused on minimal syntax
- Host: GitHub
- URL: https://github.com/spookyless/shortscript
- Owner: Spookyless
- License: mit
- Created: 2024-04-25T10:19:10.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-06-14T13:43:07.000Z (over 1 year ago)
- Last Synced: 2025-05-30T07:36:27.916Z (9 months ago)
- Topics: antlr4, interpreted-programming-language, interpreter, shortscript
- Language: TypeScript
- Homepage: https://shortscript.spookyless.net/
- Size: 910 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# ShortScript
Custom interpreted language focused on minimal syntax
## Language features
- [x] interpreted
- [ ] statically typed
- [x] supports most common arithmetic and logic operations
- [x] functions and QoL loops
- [x] object-oriented
- [ ] inheritance
- [x] minimal syntax
## Grammar
[`ShortScript.g4`](./ShortScript.g4) contains the whole grammar of the language.
## Technologies used
- [ANTLR4](https://www.antlr.org/)
- [ANTLR4 for Javascript](https://github.com/antlr/antlr4/blob/master/doc/javascript-target.md)
- Other packages, listed in [package.json](./package.json)
## IDE Features

- 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`](./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

## 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](https://github.com/antlr/antlr4/blob/master/doc/getting-started.md).
For additional features (such us grammar testing), you also need to install `antlr4-tools`, using [the official documentation](https://github.com/antlr/antlr4-tools/blob/master/README.md).
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
```shell
git clone https://github.com/Spookyless/ShortScript.git
cd ShortScript
```
2. Install dependencies
```shell
npm install
```
### Running the application
4. Start the development server
```shell
npm run dev
```
5. ...or, build the application and start the production version:
```shell
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:
```shell
npm test
```
If you want more granular control over what tests are run, you can execute specified stages (found in [`package.json`](./package.json)):
```shell
npm run test:grammar
```
Test cases are located inside [`examples/grammar`](./examples/grammar) directory.
## Authors
- [@MBrosik](https://github.com/MBrosik)
- [@Spookyless](https://github.com/Spookyless)
- [@rubikon02](https://github.com/rubikon02)
## License
ShortScript is licensed under MIT License, more information can be found in the [`LICENSE.md`](./LICENSE.md) file