Skip to content

Commit

Permalink
Fix grammar doc
Browse files Browse the repository at this point in the history
  • Loading branch information
melvic-ybanez committed Nov 1, 2023
1 parent 2322d7a commit a47f773
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ The syntax of Dry should be familiar to Python and Scala developers. Here's the
<return> ::= "return" <expression>? ";"
<import> ::= "import" <identifier>("."<identifier>)* ";"
<expression> ::= <assignment> | <lambda>
<assignment> ::= (<call> | <identifier>) "=" <expression>
<call> ::= <primary> ("(" (<expression> | ("," <expression>)*)? ")" | "." <identifier>
| "[" <constant> "]")+
<assignment> ::= <call> "=" <expression>
<call> ::= <primary> ("(" (<expression> | ("," <expression>)*)? ")" | "." <identifier> | <index>)*
<index> ::= "[" <constant> "]"
<identifier> ::= <alpha>(<alpha>?<digit>?)*
<lambda> ::= "lambda" <params> <block> | <or>
<block> ::= "{" <declaration>* "}"
Expand All @@ -211,7 +211,7 @@ The syntax of Dry should be familiar to Python and Scala developers. Here's the
<term> ::= <factor> ("-" | "+" | "&" | "|" | "^" | "<<" | ">>"
| ">>>" | "<=" <factor>)*
<factor> ::= <unary> ("/" | "*" | "%" <unary>)*
<unary> ::= ("!" | "-" | "+" | "not") <expression> | <call>
<unary> ::= ("!" | "-" | "+" | "not")* <call>
<primary> ::= <constant> | "self" | <identifier> | <dictionary> | "(" <expression> ")"
<constant> ::= "false" | "true" | "none" | <number> | <string>
<dictionary> ::= "{" (<key-value> ("," <key-value>)*)? "}"
Expand Down
7 changes: 3 additions & 4 deletions src/main/scala/com/melvic/dry/parsers/ExprParser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private[parsers] trait ExprParser { _: Parser =>
assignment

/**
* {{{<assignment> ::= (<call> | <identifier>) "=" <expression>}}}
* {{{<assignment> ::= <call> "=" <expression>}}}
*/
def assignment: ParseResult[Expr] = {
// parse the left value as a lambda to cover all possible expression (including chained `get`s)
Expand Down Expand Up @@ -105,7 +105,7 @@ private[parsers] trait ExprParser { _: Parser =>
leftAssocBinary(_.unary, TokenType.Slash, TokenType.Star, TokenType.Modulo)

/**
* {{{<unary> ::= ("!" | "-" | "+") <expression> | <call>}}}
* {{{<unary> ::= ("!" | "-" | "+" | "not")* <call>}}}
*/
def unary: ParseResult[Expr] =
matchAny(TokenType.Not, TokenType.Minus, TokenType.Plus)
Expand All @@ -117,8 +117,7 @@ private[parsers] trait ExprParser { _: Parser =>

/**
* {{{
* <call> ::= <primary> ("(" (<expression> | ("," <expression>)*)? ")" | "." <identifier>
* | "[" <constant> "]")*
* <call> ::= <primary> ("(" (<expression> | ("," <expression>)*)? ")" | "." <identifier> | <index>)*
* }}}
*/
def call: ParseResult[Expr] = {
Expand Down

0 comments on commit a47f773

Please sign in to comment.