message: Fix ups needed to build from top-level and rustfmt.
diff: use logos::Logos;
  use std::convert::TryFrom;
  +use std::fmt::{self, Display, Formatter};
  /// The complete set of `LexToken`s some of which never escape the lexer.
  /// See Token for a list of which Tokens do and do not escape.
  @@ -62,8 +63,9 @@ pub enum LexToken {
  /// The subset of `LexToken`s for the parser.
  /// The tokens in `LexToken`s which are excluded from this enum are:
  -/// * Whitespace
  -/// * EOF
  +/// * Whitespace -- skipped.
  +/// * EOF -- turned into None, rather than a token.
  +/// * Error -- turned into Some(Err(...)).
  #[derive(Debug, Clone)]
  pub enum Token<'a> {
  Colon,
  @@ -88,6 +90,34 @@ pub enum Token<'a> {
  Shift(&'a str),
  }
  +impl<'a> Display for Token<'a> {
  + fn fmt(&self, f: &mut Formatter) -> fmt::Result {
  + use Token as T;
  + match self {
  + T::Colon => write!(f, ":"),
  + T::Comma => write!(f, ","),
  + T::Fun => write!(f, "Fun"),
  + T::DArrow => write!(f, "=>"),
  + T::Arrow => write!(f, "->"),
  + T::LParen => write!(f, "("),
  + T::RParen => write!(f, ")"),
  + T::LBrack => write!(f, "["),
  + T::RBrack => write!(f, "]"),
  + T::LBrace => write!(f, "{{"),
  + T::RBrace => write!(f, "}}"),
  + T::RecordTerm => write!(f, "record"),
  + T::RecordType => write!(f, "Record"),
  + T::Equal => write!(f, "="),
  + T::Dot => write!(f, "."),
  + T::CharLit(s) => write!(f, "CharLit({})", s),
  + T::StrLit(s) => write!(f, "StrLit({})", s),
  + T::Number(s) => write!(f, "Number({})", s),
  + T::Name(s) => write!(f, "Write({})", s),
  + T::Shift(s) => write!(f, "Shift({})", s),
  + }
  + }
  +}
  +
  // Not really sure whether try_from is the best way to do this.
  // In particular this only succeeds for the nullary Tokens.
  impl<'a> TryFrom<&LexToken> for Token<'a> {
  @@ -113,17 +143,23 @@ impl<'a> TryFrom<&LexToken> for Token<'a> {
  t => {
  println!("{:?}", t);
  Err("Error in converting LexicalToken to Token")
  - },
  + }
  }
  }
  }
  #[derive(Debug)]
  pub struct LexicalError(std::ops::Range<usize>, &'static str);
  +
  +impl Display for LexicalError {
  + fn fmt(&self, f: &mut Formatter) -> fmt::Result {
  + write!(f, "Lexical error: {:?} {}", self.0, self.1)
  + }
  +}
  +
  pub struct LexIterator<'a>(logos::Lexer<LexToken, &'a str>);
  pub type Spanned<Tok, Loc, Error> = Result<(Loc, Tok, Loc), Error>;
  -
  impl<'a> LexIterator<'a> {
  pub fn new(source: &'a str) -> LexIterator<'a> {
  LexIterator(LexToken::lexer(source))
  @@ -175,4 +211,3 @@ impl<'a> Iterator for LexIterator<'a> {
  it
  }
  }
  -
  