pilota_build2/parser/
mod.rs1use std::{
2 path::{Path, PathBuf},
3 sync::Arc,
4};
5
6use fxhash::FxHashMap;
7pub use thrift::ThriftParser;
8
9use crate::{ir::File, symbol::FileId};
10
11pub use self::protobuf::ProtobufParser;
12
13pub(crate) mod protobuf;
14pub(crate) mod thrift;
15
16pub struct ParseResult {
17 pub files: Vec<Arc<File>>,
18 pub(crate) input_files: Vec<FileId>,
19 pub(crate) file_ids_map: FxHashMap<Arc<PathBuf>, FileId>,
20}
21
22pub trait Parser {
23 fn input<P: AsRef<Path>>(&mut self, path: P);
24
25 fn inputs<P: AsRef<Path>>(&mut self, paths: impl IntoIterator<Item=P>) {
26 paths.into_iter().for_each(|p| self.input(p))
27 }
28
29 fn include_dirs(&mut self, dirs: Vec<PathBuf>);
30
31 fn parse(self) -> ParseResult;
32}