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