Skip to content
[WIP] Javascript library for parsing SC2's Galaxy scripting language.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin
lib
test
.gitignore
.gitmodules
.travis.yml
LICENSE
README.md
package.json

README.md

Galaxy Parser Build Status

Notes

Extended Backus–Naur Form Grammar

<program> ::= {<toplevel-declaration>}
<toplevel-declaration> ::= <struct-declaration>
  | <global-declaration>
  | <type-def>
  | <function-declaration>
  | <function-prototype>
  | <native-declaration>

<global-declaration> ::= ["static"] ["const"] <variable-declaration> ";"
<variable-declaration> ::= <type-specifier> <identifier> []

<struct-declaration> ::= "struct" "{" {<struct-field>} "}"
<struct-field> ::= <type-specifier> <identifier>  ";"

<function-prototype> ::= ["static"] <type-specifier> <identifier> "(" ")" ";"

<function-declaration> ::= ["static"] <type-specifier> <identifier> "(" ")" "{" <function-body> "}"

<type-specifier> ::= <identifier>
  | <type-specifier> "[" <integer-literal> "]"
  | <identifier> "<" <identifier> ">"

<type-def> ::= "typedef" <type-specifier> <identifier> ";"
<include-path> ::= "import" <string-literal> [";"]

<function-body> ::= {<variable-declaration> ";"}

<statement> ::= <expression>
  | <identifier> <assign-op> <expression> // TODO: Determine if assignment is a statement or expression.
  | "return" <expression>
  | "continue"
  | "break"

<expression> ::= <expression> <bin-op> <expression> // Binary operator.
  | <unary-op> <expression> // Unary operator.
  | <identifier> "[" "]" // Array indexing.
  | <identifier> "(" [<expresion_list>] ")" // Function call.
  | <identifier> // Scope lookup.
  | <string-literal> // String literal.

<expresion_list> ::= {<expresion> ","} <expresion>

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

<unary-op> ::= "+" | "-" | "~" | "!"

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

Links

You can’t perform that action at this time.