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
// SPDX-License-Identifier: LGPL-2.1-or-later
// See Notices.txt for copyright information
pub mod ast;

pub use ast::parse;

macro_rules! parse_path {
    ($path:expr) => {
        ast::parse($path, include_str!($path))
            .map_err(|e| e.to_string())
            .unwrap()
    };
}

pub fn parse_rvc_instr_table() -> ast::InstructionSet {
    parse_path!(concat!(
        env!("CARGO_MANIFEST_DIR"),
        "/riscv-isa-manual/src/rvc-instr-table.tex"
    ))
}

pub fn parse_instr_table() -> ast::InstructionSet {
    parse_path!(concat!(
        env!("CARGO_MANIFEST_DIR"),
        "/riscv-isa-manual/src/instr-table.tex"
    ))
}

#[cfg(test)]
mod test {
    #[test]
    fn test_parse_instr_table() {
        crate::parse_instr_table();
    }

    #[test]
    fn test_parse_rvc_instr_table() {
        crate::parse_rvc_instr_table();
    }
}