Added function calls and bindings to grammar
This commit is contained in:
parent
df0c370059
commit
f1b373c7e6
19
grammar.txt
19
grammar.txt
@ -1,12 +1,12 @@
|
|||||||
expression ->
|
expression ->
|
||||||
| sequence
|
| sequence
|
||||||
// | apply
|
| apply
|
||||||
| unary
|
| unary
|
||||||
| binary
|
| binary
|
||||||
| let
|
| let
|
||||||
| compound
|
| compound
|
||||||
| control
|
| control
|
||||||
| field
|
| selector
|
||||||
| index
|
| index
|
||||||
| identifier
|
| identifier
|
||||||
| primary
|
| primary
|
||||||
@ -19,22 +19,25 @@ operator ->
|
|||||||
| "+" | "-" | "*" | "/"
|
| "+" | "-" | "*" | "/"
|
||||||
| "|>" | "<|" | ">>" | "<<"
|
| "|>" | "<|" | ">>" | "<<"
|
||||||
| "++" ;
|
| "++" ;
|
||||||
pattern -> "_" | record_pattern | variant_pattern | identifier ;
|
pattern -> "_" | record_pattern | variant_pattern ;
|
||||||
record_pattern -> "{" ( identifier ( "=" pattern )? ( "," identifier ( "=" pattern )? )* ) ( "|" identifier ) "}"
|
record_pattern -> "{" ( identifier ( "=" pattern )? ( "," identifier ( "=" pattern )? )* ) ( "|" identifier ) "}"
|
||||||
variant_pattern -> "`" identifier ( "(" ( "_" | compound_pattern | identifier ) ")" )? ;
|
variant_pattern -> "`" identifier ( "(" ( "_" | compound_pattern | identifier ) ")" )? ;
|
||||||
let -> "let" pattern "=" expression ( "and" pattern "=" expression )* "in" expression ;
|
parameters -> "(" ( identifier ( "," identifier )* )?")"
|
||||||
|
let -> "let" ( identifier parameters? | pattern ) "=" expression ( "and" ( identifier parameters? | pattern ) "=" expression )* "in" expression ;
|
||||||
control ->
|
control ->
|
||||||
| if
|
| if
|
||||||
| when
|
| when
|
||||||
if -> "if" expression "then" expression "else" expression ;
|
if -> "if" expression "then" expression "else" expression ;
|
||||||
when -> "when" expression "is" ( pattern "=>" expression )+ ;
|
when -> "when" expression "is" ( ( identifier | pattern ) "=>" expression )+ ;
|
||||||
compound -> variant | record | list ;
|
compound -> variant | record | list ;
|
||||||
variant -> "`" identifier ( "(" 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 )* "}" ;
|
||||||
list -> "[" ( expression ( "," expression )* )? "]" ;
|
list -> "[" ( expression ( "," expression )* )? "]" ;
|
||||||
field -> expression "." identifier ;
|
|
||||||
index -> expression "[" expression "]" ;
|
|
||||||
identifier -> IDENTIFIER | "@" STRING ;
|
identifier -> IDENTIFIER | "@" STRING ;
|
||||||
primary -> NUMBER | STRING | identifier | "(" expression ")" ;
|
operand -> ( NUMBER | STRING | identifier | "(" expression ")" ) ;
|
||||||
|
selector -> "." identifier ;
|
||||||
|
index -> "[" expression "]" ;
|
||||||
|
arguments -> "(" ( "_" | expression ( "," ( "_" | expression ) )* )? ")" ;
|
||||||
|
primary -> operand ( selector | index | arguments ) ;
|
||||||
|
Loading…
Reference in New Issue
Block a user