-
Notifications
You must be signed in to change notification settings - Fork 1
Grammar
Nick Smith edited this page Jul 21, 2018
·
7 revisions
This is the formal grammar for the current version of Parakeet
<compound statement> ::= <statement> <eol> | <statement> <eol> <compound statement>
<statement> ::= <expression> | <assign> | <id> | <type declaration> | <id> <arguments>
<expression> ::= <term> | <expression> "+" <term> | <expression> "-" <term>
<term> ::= <pow> | <term> "*" <pow> | <term> "/" <pow> | <term> "%" <pow>
<pow> ::= <factor> | <pow> "^" <factor>
<factor> ::= <int> | <float> | <str> | <char> | "(" <expression> ")" | <id>
<string> ::= """ <string contents> """ | "'" <string contents> "'"
<string contents> ::= "" | <char> <string contents>
<int> ::= "" | <num> <int>
<float> ::= "" | <int> "." <int>
<num> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
<char> ::= -- Any Unicode Character --
<alphabetic char> ::= -- Any Alphabetic Character --
<assign> ::= "let" <id> <assign value> | "let" <id> "(" <arguments> ")" <assign value>
<assign value> ::= "=" <statement> | "= {" <compound statement> "}"
<id> ::= <alphabetic char> <id tail>
<id tail> ::= "" | <allowed id char> <id tail>
<allowed id char> ::= -- Any Unicode Character excluding : --
<eol> ::= "\n" | ";"
<type declaration> ::= <id> ":" <id>
<arguments> ::= <type declaration> ", " <arguments> | <type declaration>