From 94ae88b363ed066c6a1fd3c4bec4690fa4119ee0 Mon Sep 17 00:00:00 2001 From: Caleb Jones Date: Fri, 30 Dec 2016 16:33:38 -0500 Subject: [PATCH] Document ParseError --- src/parser.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/parser.rs b/src/parser.rs index 2ae99b7..48e8161 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -23,15 +23,38 @@ pub enum ParseResult<'a, T, E> { } /// Indicates how parsing failed. +/// +/// Most `ParseError` variants contain a `Box` that represents the +/// cause of that error. Using this, `ParseError` variants can be chained to +/// produce a more complete picture of what exactly went wrong during parsing. #[derive(Debug, PartialEq, Eq, Clone)] pub enum ParseError where Loc: Span { + /// Parsing reached the end of input where not expecting to, usually this + /// will be contained inside another `ParseError` like `String(box + /// UnexpectedEof, ...)` which indicates that the closing quote was never + /// found. UnexpectedEof, + /// Some problem occurred while parsing a list, along with the cause of that + /// error. List(Box, Loc), + /// Some problem occurred while parsing an s-expression. This will only be + /// generated if EOF is reached unexpectedly at the beginning of + /// `parse_expression`, so it should probably be removed. Sexp(Box, Loc), + /// Some problem occurred while parsing a character literal, along with the + /// cause of the error. Char(Box, Loc), + /// Some problem occurred while parsing a string literal, along with the + /// cause of the error. String(Box, Loc), + /// Some problem occurred while parsing a symbol, along with the cause of + /// the error. Symbol(Box, Loc), + /// Some problem occurred while parsing a number literal, along with the + /// cause of the error. Number(Box, Loc), + /// An unexpected character was found. This will usually be the root cause + /// in some chain of `ParseError`s. Unexpected(char, Loc::Begin), } use self::ParseResult::*; -- 2.43.2