Releases: melvic-ybanez/dry
Releases · melvic-ybanez/dry
v0.1.0
This is the initial release of the Dry programming language.
It implements the following grammar (but see bottom notes as well):
<declaration> ::= <class> | <function> | <let> | <statement>
<class> ::= "class" <identifier> "{" <function>* "}"
<function> ::= "def" <identifier> <params> <block>
<let> ::= "let" <identifier> ("=" <expression>)? ";"
<statement> ::= <expr-stmt> | <block> | <if> | <while> | <for> | <return> | <import>
<expr-stmt> ::= <expression> ";"
<if> ::= "if" "(" <expression> ")" <statement> ("else" <statement>)?
<while> ::= "while" "(" <expression> ")" <statement>
<for> ::= "for" "(" (";" | <let> | <expr-stmt>)
(<expression>? ";") <expression> ")" <statement>
<return> ::= "return" <expression>? ";"
<import> ::= "import" <identifier>("."<identifier>)* ";"
<expression> ::= <assignment>
<assignment> ::= (<call>".")?<identifier> "=" <assignment> | <lambda>
<call> ::= <primary> ("(" (<expression> | ("," <expression>)*)? ")" | "." <identifier>)
<identifier> ::= <alpha>(<alpha>?<digit>?)*
<lambda> ::= "lambda" <params> <block> | <or>
<block> ::= "{" <declaration>* "}"
<params> ::= "(" (<identifier> | ("," <identifier>)*)? ")"
<or> ::= <and> ("or" <and>)*
<and> ::= <equality> ("and" <equality>)*
<equality> ::= <comparison> ("!=" | "==" <comparison>)*
<comparison> ::= <term> (">" | ">=" | "<" | "<=" <term>)*
<term> ::= <factor> ("-" | "+" | "&" | "|" | "^" | "<<" | ">>"
| ">>>" | "<=" <factor>)*
<factor> ::= <unary> ("/" | "*" | "%" <unary>)*
<unary> ::= ("!" | "-") <expression> | <call>
<primary> ::= "false" | "true" | "none" | <number> | <string>
| "self" | <identifier> | "(" <expression> ")"
<number> ::= <sign>?<nat>("."<nat>)?
<sign> ::= "-" | "+"
<string> ::= '"'(.?"\n"?)*'"'
<alpha> ::= 'a' ... 'z' | 'A' ... 'Z' | '_'
<nat> ::= <digit><digit>*
<digit> ::= '0' ... '9'
Edit: Apparently the grammar above did not match the implementation in this release.