| 
					
				 | 
			
			
				@@ -198,6 +198,9 @@ pub enum ParseErrorKind { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     #[error("Aliases cannot be used on functions.")] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     AliasUsedOnFunction, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    #[error("Example decorators can only be used on functions.")] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ExampleUsedOnUnsuitableKind, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     #[error("Numerical overflow in dimension exponent")] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     OverflowInDimensionExponent, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -456,6 +459,14 @@ impl Parser { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             span: self.peek(tokens).span, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if decorator::contains_examples(&self.decorator_stack) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        return Err(ParseError { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            kind: ParseErrorKind::ExampleUsedOnUnsuitableKind, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            span: self.peek(tokens).span, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     std::mem::swap(&mut decorators, &mut self.decorator_stack); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -735,6 +746,55 @@ impl Parser { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                "example" => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if self.match_exact(tokens, TokenKind::LeftParen).is_some() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if let Some(token_code) = self.match_exact(tokens, TokenKind::StringFixed) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            if self.match_exact(tokens, TokenKind::Comma).is_some() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                //Code and description 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                if let Some(token_description) = 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    self.match_exact(tokens, TokenKind::StringFixed) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    if self.match_exact(tokens, TokenKind::RightParen).is_none() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        return Err(ParseError::new( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                            ParseErrorKind::MissingClosingParen, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                            self.peek(tokens).span, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        )); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    Decorator::Example( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        strip_and_escape(&token_code.lexeme), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        Some(strip_and_escape(&token_description.lexeme)), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    return Err(ParseError { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        kind: ParseErrorKind::ExpectedString, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        span: self.peek(tokens).span, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                //Code but no description 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                if self.match_exact(tokens, TokenKind::RightParen).is_none() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    return Err(ParseError::new( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        ParseErrorKind::MissingClosingParen, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        self.peek(tokens).span, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    )); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                Decorator::Example(strip_and_escape(&token_code.lexeme), None) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            return Err(ParseError { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                kind: ParseErrorKind::ExpectedString, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                span: self.peek(tokens).span, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        return Err(ParseError { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            kind: ParseErrorKind::ExpectedLeftParenAfterDecorator, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            span: self.peek(tokens).span, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 _ => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     return Err(ParseError { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         kind: ParseErrorKind::UnknownDecorator, 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -769,6 +829,13 @@ impl Parser { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             let unit_name = identifier.lexeme.to_owned(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if decorator::contains_examples(&self.decorator_stack) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return Err(ParseError { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    kind: ParseErrorKind::ExampleUsedOnUnsuitableKind, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    span: self.peek(tokens).span, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             let mut decorators = vec![]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             std::mem::swap(&mut decorators, &mut self.decorator_stack); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2795,6 +2862,24 @@ mod tests { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        parse_as( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            &["@name(\"Some function\") @example(\"some_function(2)\", \"Use this function:\") @example(\"let some_var = some_function(0)\") fn some_function(x) = 1"], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Statement::DefineFunction { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                function_name_span: Span::dummy(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                function_name: "some_function".into(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                type_parameters: vec![], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                parameters: vec![(Span::dummy(), "x".into(), None)], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                body: Some(scalar!(1.0)), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                local_variables: vec![], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return_type_annotation: None, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                decorators: vec![ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    decorator::Decorator::Name("Some function".into()), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    decorator::Decorator::Example("some_function(2)".into(), Some("Use this function:".into())), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    decorator::Decorator::Example("let some_var = some_function(0)".into(), None), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         parse_as( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             &["fn double_kef(x) = y where y = x * 2"], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             Statement::DefineFunction { 
			 |