Created
May 10, 2017 01:27
-
-
Save shardulc/90be98f59b458480a8b7f9523c3e5ff4 to your computer and use it in GitHub Desktop.
Initial GoD language spec draft
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
statement := (declaration | assignment | call | control) '\n' | |
declaration := (('num' | 'str' | 'flag' | 'list' | 'func') ident) | |
| ('num' ident '=' numexpr) | |
| ('str' ident '=' strexpr) | |
| ('flag' ident '=' flagexpr) | |
| ('list' ident '=' listexpr) | |
| ('func' ident '=' funcexpr) | |
assignment := ident '=' expr | |
call := ident '(' params ')' | |
control := ifctrl | whilectrl | forctrl | |
ifctrl := ifclause elifclause* elseclause? | |
ifclause := 'if' flagexpr '{' statement* '}' | |
elifclause := 'else' ifclause | |
elseclause := 'else' '{' statement* '}' | |
whilectrl := 'while' flagexpr '{' statement* '}' | |
forctrl := 'for' ident 'in' listexpr '{' statement* '}' | |
ident := character+ | |
expr := numexpr | strexpr | flagexpr | listexpr | funcexpr | |
params := (expr ',')* (expr | null) | |
flagexpr := 'true' | 'false' | call | ('(' flagexpr ')') | |
| ('not' flagexpr) | (flagexpr ('and' | 'or') flagexpr) | |
| (numexpr ('<' | '>' | '<=' | '>=' | '==' | '!=' ) numexpr) | |
listexpr := ('[' (expr ',')* (expr | null) ']') | call | (listexpr '+' expr) | |
funcexpr := '(' (ident ',')* (ident | null) ')' '{' statement* '}' | |
numexpr := number | call | '(' numexpr ')' | (numexpr [-+*/%] numexpr) | |
strexpr := string | call | (strexpr '+' strexpr) | |
number := numeral+ ('.' numeral+)? | |
string := ''' character+ ''' | |
character := [0-9a-zA-Z_-] | |
numeral := [0-9] | |
null := '' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment