1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use std::borrow::Cow;

use pest;
use pest_derive::Parser;

#[derive(Parser)]
#[grammar = "parser.pest"]
pub struct ChParser;

pub mod ast;
pub mod compile;
pub mod verify;

/// Error types.
#[derive(Debug, Clone, PartialEq)]
pub enum Error {
    /// Some type somewhere doesn't line up.
    /// Desired type, actual type
    TypeMismatch(ast::Type, ast::Type),
    /// Some other validation step failed.
    Validation(Cow<'static, str>),
    /// Tried to redefine a name
    SymbolExists(Cow<'static, str>),
    /// Something went wrong with SPIR-V generation
    /// TODO: Include the rspirv error once it's useful.
    CodegenError, //(rspirv::mr::Error),
}

impl From<rspirv::mr::Error> for Error {
    fn from(_e: rspirv::mr::Error) -> Error {
        Error::CodegenError //(e)
    }
}

#[cfg(test)]
mod tests {
    use super::*;
    use pest::Parser;

    #[test]
    fn parser_test() {
        let input = "hello world";
        let _pairs = ChParser::parse(Rule::ident, input).unwrap();
    }
}