diff --git a/schala-lang/language/src/parsing.rs b/schala-lang/language/src/parsing.rs index 4841041..1706ef5 100644 --- a/schala-lang/language/src/parsing.rs +++ b/schala-lang/language/src/parsing.rs @@ -10,7 +10,7 @@ //! //! ## Top level structure //! -//! ``` +//! ```text //! program := (statement delimiter)* EOF //! delimiter := NEWLINE | ";" //! statement := expression | declaration @@ -20,7 +20,7 @@ //! ## Declarations //! //! ### Types -//! ``` +//! ```text //! type_declaration := "type" type_declaration_body //! type_declaration_body := "alias" type_alias | "mut"? type_singleton_name "=" type_body //! type_alias := IDENTIFIER "=" type_name @@ -31,7 +31,7 @@ //! ``` //! ### Functions //! -//! ``` +//! ```text //! func_declaration := func_signature func_body //! func_body := ε | nonempty_func_body //! nonempty_func_body := "{" (statement delimiter)* "}" @@ -42,11 +42,11 @@ //! ``` //! //! ### Variable bindings -//! ```binding_declaration := "let" "mut"? IDENTIFIER "=" expresion``` +//! ```text binding_declaration := "let" "mut"? IDENTIFIER "=" expresion``` //! //! ### Interfaces //! -//! ``` +//! ```text //! interface_declaration := "interface" type_singleton_name signature_block //! impl_declaration := "impl" type_singleton_name decl_block | "impl" type_singleton_name "for" type_name decl_block //! decl_block := "{" (func_declaration)* "}" @@ -55,7 +55,7 @@ //! //! ### Type Annotations //! -//! ``` +//! ```text //! type_anno := ":" type_name //! type_name := type_singleton_name | "(" type_names ")" //! type_names := ε | type_name (, type_name)* @@ -64,7 +64,7 @@ //! ``` //! //! ## Expressions -//! ``` +//! ```text //! expression := precedence_expr type_anno+ //! precedence_expr := prefix_expr //! prefix_expr := prefix_op call_expr @@ -79,7 +79,7 @@ //! //! ### Primary expressions //! -//! ``` +//! ```text //! list_expr := "[" (expression, ",")* "]" //! lambda_expr := "\\" lambda_param_list type_anno+ nonempty_func_body //! lambda_param_list := formal_param_list | formal_param @@ -89,7 +89,7 @@ //! ``` //! //! ## Literals -//! ``` +//! ```text //! literal := "true" | "false" | number_literal | STR_LITERAL //! named_struct := IDENTIFIER record_block //! record_block := "{" (record_entry, ",")* | "}" //TODO support anonymus structs, update syntax @@ -103,7 +103,7 @@ //! ``` //! //! ### Patterns -//! ``` +//! ```text //! pattern := "(" (pattern, ",")* ")" | simple_pattern //! simple_pattern := pattern_literal | record_pattern | tuple_struct_pattern //! pattern_literal := "true" | "false" | signed_number_literal | STR_LITERAL | IDENTIFIER @@ -114,7 +114,7 @@ //! ``` //! //! ### 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 @@ -126,7 +126,7 @@ //! ``` //! //! ### While expressions -//! ``` +//! ```text //! while_expr := "while" while_cond "{" (statement delimiter)* "}" //! while_cond := ε | expression | expression "is" pattern //TODO maybe is-expresions should be primary //! ``` @@ -134,7 +134,7 @@ //! //TODO this implies there must be at least one enumerator, which the parser doesn"t support right //! //this second, and maybe should fail later anyway //! ### For-expressions -//! ``` +//! ```text //! for_expr := "for" (enumerator | "{" enumerators "}") for_expr_body //! for_expr_body := "return" expression | "{" (statement delimiter)* "}" //! enumerators := enumerator ("," enumerators)* @@ -642,9 +642,9 @@ impl Parser { InvocationArgument::Ignored }, Identifier(s) => { - self.token_handler.next(); - match self.token_handler.peek_kind() { + match self.token_handler.peek_kind_n(1) { Operator(ref op) if **op == "=" => { + self.token_handler.next(); self.token_handler.next(); let expr = self.expression()?; InvocationArgument::Keyword { name: s.clone(), expr }