qbe-reader

A parser for the QBE intermediate language in Rust

git clone https://git.8pit.net/qbe-reader.git

 1use std::io;
 2use std::str;
 3
 4#[derive(Debug)]
 5pub enum Error {
 6    IncompleteParse,
 7    ParsingError(String, nom::error::ErrorKind),
 8    IoError(io::Error),
 9}
10
11impl From<nom::Err<nom::error::Error<&str>>> for Error {
12    fn from(e: nom::Err<nom::error::Error<&str>>) -> Self {
13        match e {
14            nom::Err::Incomplete(_) => Error::IncompleteParse,
15            nom::Err::Error(e) | nom::Err::Failure(e) => {
16                Error::ParsingError(e.input.to_string(), e.code)
17            }
18        }
19    }
20}
21
22impl From<io::Error> for Error {
23    fn from(e: io::Error) -> Self {
24        Error::IoError(e)
25    }
26}