Added let-exprs to grammar, and fixed patterns
This commit is contained in:
parent
138508732f
commit
df0c370059
13
grammar.txt
13
grammar.txt
@ -3,7 +3,7 @@ expression ->
|
|||||||
// | apply
|
// | apply
|
||||||
| unary
|
| unary
|
||||||
| binary
|
| binary
|
||||||
// | let
|
| let
|
||||||
| compound
|
| compound
|
||||||
| control
|
| control
|
||||||
| field
|
| field
|
||||||
@ -17,16 +17,19 @@ binary -> expression operator expression ;
|
|||||||
operator ->
|
operator ->
|
||||||
| "==" | "!=" | "<" | "<=" | ">" | ">="
|
| "==" | "!=" | "<" | "<=" | ">" | ">="
|
||||||
| "+" | "-" | "*" | "/"
|
| "+" | "-" | "*" | "/"
|
||||||
// | "|>" | "<|" | ">>" | "<<"
|
| "|>" | "<|" | ">>" | "<<"
|
||||||
| "++" ;
|
| "++" ;
|
||||||
|
pattern -> "_" | record_pattern | variant_pattern | identifier ;
|
||||||
|
record_pattern -> "{" ( identifier ( "=" pattern )? ( "," identifier ( "=" pattern )? )* ) ( "|" identifier ) "}"
|
||||||
|
variant_pattern -> "`" identifier ( "(" ( "_" | compound_pattern | identifier ) ")" )? ;
|
||||||
|
let -> "let" pattern "=" expression ( "and" pattern "=" expression )* "in" expression ;
|
||||||
control ->
|
control ->
|
||||||
| if
|
| if
|
||||||
| when
|
| when
|
||||||
if -> "if" expression "then" expression "else" expression ;
|
if -> "if" expression "then" expression "else" expression ;
|
||||||
variant_pattern -> "`" identifier ( "(" ( ( "_" | identifier ) ( "," ( "_" | identifier )* )? ) ")" )? ;
|
when -> "when" expression "is" ( pattern "=>" expression )+ ;
|
||||||
when -> "when" expression "is" ( variant_pattern "=>" expression )+ ;
|
|
||||||
compound -> variant | record | list ;
|
compound -> variant | record | list ;
|
||||||
variant -> "`" identifier ( "(" ( expression ( "," expression)* )? ")" )? ;
|
variant -> "`" identifier ( "(" expression ")" )? ;
|
||||||
base_record -> expression ( "with" identifier "=" expression ( "," "with" identifier "=" expression )* )?
|
base_record -> expression ( "with" identifier "=" expression ( "," "with" identifier "=" expression )* )?
|
||||||
record ->
|
record ->
|
||||||
"{" ( identifier ("=" expression)? ( "," identifier ("=" expression)? )* )? ( "|" base_record )* "}" ;
|
"{" ( identifier ("=" expression)? ( "," identifier ("=" expression)? )* )? ( "|" base_record )* "}" ;
|
||||||
|
Loading…
Reference in New Issue
Block a user