An open API service indexing awesome lists of open source software.

https://github.com/rameshvarun/galaxy-parser

A parser for StarCraft 2's Galaxy scripting language, written in JavaScript using parser combinators.
https://github.com/rameshvarun/galaxy-parser

parser parser-combinator starcraft2

Last synced: 20 days ago
JSON representation

A parser for StarCraft 2's Galaxy scripting language, written in JavaScript using parser combinators.

Awesome Lists containing this project

README

        

# StarCraft 2 Galaxy Parser

[![Node.js CI](https://github.com/rameshvarun/galaxy-parser/actions/workflows/node.js.yml/badge.svg)](https://github.com/rameshvarun/galaxy-parser/actions/workflows/node.js.yml)
[![npm](https://img.shields.io/npm/v/sc2-galaxy-parser)](https://www.npmjs.com/package/sc2-galaxy-parser)

## Usage

```javascript
const parse = require("sc2-galaxy-parser");
const ast = parse(`void Main(int argc, string[100] argv) {
ConsoleLog("Galaxy Test...");
}`);
console.log(ast);
```

## Notes
### Extended Backus–Naur Form Grammar
```
::= {}
::=
|
|
|
|
|

::= ["static"] ["const"] ";"
::= []

::= "struct" "{" {} "}"
::= ";"

::= ["static"] "(" ")" ";"

::= ["static"] "(" ")" "{" "}"

::=
| "[" "]"
| "<" ">"

::= "typedef" ";"
::= "import" [";"]

::= { ";"}

::=
| // TODO: Determine if assignment is a statement or expression.
| "return"
| "continue"
| "break"

::= // Binary operator.
| // Unary operator.
| "[" "]" // Array indexing.
| "(" [] ")" // Function call.
| // Scope lookup.
| // String literal.

::= { ","}

::= "+" | "-" | "*" | "/" | "%" | "&"
| "|" | "^" | "<<" | ">>" | "&&" | "||" | "=="
| "!=" | "<" | "<=" | ">=" | ">"

::= "+" | "-" | "~" | "!"

::= "=" | "+=" | "-=" | "*=" | "/="
| "%=" | "&=" | "|=" | "^=" | "<<=" | ">>="
```
## Links
- [Galaxy Parser in Haskell (Using Parser Combinators)](https://github.com/phyrex1an/galaxy-parser)
- [Galaxy Language Overview](http://www.sc2mapster.com/wiki/galaxy/script/language-overview/)
- [Galaxy Operators](http://deaod.de/GalaxyOperators.txt)
- [Galaxy Types](http://deaod.de/GalaxyTypes.txt)