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.
- Host: GitHub
- URL: https://github.com/rameshvarun/galaxy-parser
- Owner: rameshvarun
- License: mit
- Created: 2015-11-09T12:44:02.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-08-12T04:47:28.000Z (9 months ago)
- Last Synced: 2025-04-05T01:35:47.645Z (24 days ago)
- Topics: parser, parser-combinator, starcraft2
- Language: JavaScript
- Homepage:
- Size: 109 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# StarCraft 2 Galaxy Parser
[](https://github.com/rameshvarun/galaxy-parser/actions/workflows/node.js.yml)
[](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)