Alter grammar of if-blocks

This commit is contained in:
greg 2019-10-10 02:34:56 -07:00
parent 24b48551dc
commit 61b757313d

View File

@ -113,19 +113,26 @@
//! record_pattern_entry := IDENTIFIER | IDENTIFIER ":" Pattern
//! tuple_struct_pattern := qualified_identifier "(" (pattern, ",")* ")"
//! ```
//! ### If expressions
//!
//! TODO: it would be nice if the grammar could capture an incomplete precedence expr in the
//! discriminator
//!
//! ### If-expressions
//! ```text
//! if_expr := "if" discriminator ("then" condititional | "is" simple_pattern_match | guard_block)
//! discriminator := precedence_expr (operator)+
//! conditional := expr_or_block else_clause
//! simple_pattern_match := pattern "then" conditional
//! else_clause := ε | "else" expr_or_block
//! guard_block := "{" (guard_arm, ",")* "}"
//! guard_arm := guard "then" expr_or_block | "else" expr_or_block
//! guard := "is" pattern | (operator)+ precedence_expr
//! if_expr := "if" discriminator ("then" simple_conditional | "is" simple_pattern_match | cond_block)
//! discriminator := ε | expression
//! simple_conditional := expr_or_block else_clause
//! simple_pattern_match := pattern "then" simple_conditional
//! else_clause := "else" expr_or_block
//!
//! cond_block := "{" (cond_arm comma_or_delimiter)* "}"
//! cond_arm := condition guard "then" expr_or_block
//! condition := "is" pattern | operator precedence_expr | expression
//! guard := "if" expression
//! comma_or_delimiter := "," | delimiter
//! ```
//!
//!
//! ### While expressions
//! ```text
//! while_expr := "while" while_cond "{" (statement delimiter)* "}"