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 //! record_pattern_entry := IDENTIFIER | IDENTIFIER ":" Pattern
//! tuple_struct_pattern := qualified_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 //! ```text
//! if_expr := "if" discriminator ("then" condititional | "is" simple_pattern_match | guard_block) //! if_expr := "if" discriminator ("then" simple_conditional | "is" simple_pattern_match | cond_block)
//! discriminator := precedence_expr (operator)+ //! discriminator := ε | expression
//! conditional := expr_or_block else_clause //! simple_conditional := expr_or_block else_clause
//! simple_pattern_match := pattern "then" conditional //! simple_pattern_match := pattern "then" simple_conditional
//! else_clause := ε | "else" expr_or_block //! else_clause := "else" expr_or_block
//! guard_block := "{" (guard_arm, ",")* "}" //!
//! guard_arm := guard "then" expr_or_block | "else" expr_or_block //! cond_block := "{" (cond_arm comma_or_delimiter)* "}"
//! guard := "is" pattern | (operator)+ precedence_expr //! cond_arm := condition guard "then" expr_or_block
//! condition := "is" pattern | operator precedence_expr | expression
//! guard := "if" expression
//! comma_or_delimiter := "," | delimiter
//! ``` //! ```
//! //!
//!
//! ### While expressions //! ### While expressions
//! ```text //! ```text
//! while_expr := "while" while_cond "{" (statement delimiter)* "}" //! while_expr := "while" while_cond "{" (statement delimiter)* "}"