SphereScript Specification
Chad Austin
1.2.2000


Backus-Naur Form
----------------

<program>       ::= ( <global> )*
<global>        ::= <variable decl> | <function> | <user type>
<variable decl> ::= <data type> <identifier> [ ',' <identifier> ]* ';'
<data type>     ::= 'int' | 'float' | 'bool' | 'string'
<digit>         ::= '0..9'
<number>        ::= ( <digit> )+
<identifier>    ::= <alpha> [ <alpha> | <digit> ]*
<alpha>         ::= 'a..z' | 'A..Z' | '_'
<string>        ::= '"' [ <character> ]* '"'
<user type>     ::= 'type' <identifier> '{' ( <variable decl> )* '}'

<function>      ::= <return type> <identifer> '(' <argument list> ')' <block>
<return type>   ::= 'void' | <data type>
<argument list> ::= [ <argument> [ ',' <argument> ]* ]
<argument>      ::= <data type> <identifier>
<block>         ::= <statement> | ( '{' ( <statement> )* '}' )
<statement>     ::= <variable decl> | ( <expression> ';' ) | <return> | <if> | <while> | <do while> | <do until> | <switch>
<return>        ::= 'return' <expression> ';'
<if>            ::= 'if' '(' <expression> ')' <block>
<while>         ::= 'while' '(' <expression> ')' <block>
<do while>      ::= 'do' <block> 'while' '(' <expression> ')'
<do until>      ::= 'do' <block> 'until' '(' <expression> ')'
<switch>        ::= 'switch' '(' <expression> ')' '{' ( <case> )* '}'
<case>          ::= 'case' <expression> ':' <block>

<assignop>      ::= '='
<logicop>       ::= '|' | '&'
<compop>        ::= '==' | '<' | '>' | '<=' | '>='
<addop>         ::= '+' | '-'
<mulop>         ::= '*' | '/'

<expression>    ::= ( <lvalue> [ <assignop> <expression> ]* ) | <logic expr>
<logic expr>    ::= <comp expr> [ <logicop> <comp expr> ]*
<comp expr>     ::= <add expr> [ <compop> <add expr> ]*
<add expr>      ::= <mul expr> [ <addop> <mul expr> ]*
<mul expr>      ::= <term> [ <mulop> <term> ]*
<term>          ::= <number> | <string> | <variable> | <function call> | ( '(' <expression> ')' )
