[−][src]Struct lrpar::CTParserBuilder
A CTParserBuilder allows one to specify the criteria for building a statically generated
parser.
Methods
impl CTParserBuilder<u32>[src]
pub fn new() -> Self[src]
Create a new CTParserBuilder.
Examples
CTParserBuilder::new()
.process_file_in_src("grm.y")
.unwrap();
impl<StorageT> CTParserBuilder<StorageT> where
StorageT: 'static + Debug + Hash + PrimInt + Serialize + TypeName + Unsigned,
usize: AsPrimitive<StorageT>,
u32: AsPrimitive<StorageT>, [src]
StorageT: 'static + Debug + Hash + PrimInt + Serialize + TypeName + Unsigned,
usize: AsPrimitive<StorageT>,
u32: AsPrimitive<StorageT>,
pub fn new_with_storaget() -> Self[src]
Create a new CTParserBuilder.
StorageT must be an unsigned integer type (e.g. u8, u16) which is big enough to index
(separately) all the tokens, rules, and productions in the grammar and less than or
equal in size to usize (e.g. on a 64-bit machine u128 would be too big). In other
words, if you have a grammar with 256 tokens, 256 rules, and 256 productions, you
can safely specify u8 here; but if any of those counts becomes 256 you will need to
specify u16. If you are parsing large files, the additional storage requirements of
larger integer types can be noticeable, and in such cases it can be worth specifying a
smaller type. StorageT defaults to u32 if unspecified.
Examples
CTParserBuilder::<u8>::new_with_storaget()
.process_file_in_src("grm.y")
.unwrap();
pub fn recoverer(self, rk: RecoveryKind) -> Self[src]
Set the recoverer for this parser to rk.
pub fn process_file_in_src(
&mut self,
srcp: &str
) -> Result<HashMap<String, StorageT>, Box<dyn Error>>[src]
&mut self,
srcp: &str
) -> Result<HashMap<String, StorageT>, Box<dyn Error>>
Given the filename x/y.z as input, statically compile the grammar src/x/y.z into a Rust
module which can then be imported using lrpar_mod!(x_y). This is a convenience function
around process_file which makes it easier to compile .y files
stored in a project's src/ directory.
Note that leaf names must be unique within a single project, even if they are in different
directories: in other words, y.z and x/y.z will both be mapped to the same module y_z
(and it is undefined which of the input files will "win" the compilation race).
Panics
If StorageT is not big enough to index the grammar's tokens, rules, or
productions.
pub fn yacckind(self, yk: YaccKind) -> Self[src]
Set the YaccKind for this parser to ak.
pub fn error_on_conflicts(self, b: bool) -> Self[src]
If set to true, process_file_in_src will return an error if the given grammar contains
any Shift/Reduce or Reduce/Reduce conflicts. Defaults to true.
pub fn conflicts(
&self
) -> Option<(&YaccGrammar<StorageT>, &StateGraph<StorageT>, &StateTable<StorageT>, &Conflicts<StorageT>)>[src]
&self
) -> Option<(&YaccGrammar<StorageT>, &StateGraph<StorageT>, &StateTable<StorageT>, &Conflicts<StorageT>)>
If there are any conflicts in the grammar, return a tuple which allows users to inspect
and pretty print them; otherwise returns None. Note: The conflicts feature is currently
unstable and may change in the future.
pub fn process_file<P, Q>(
&mut self,
inp: P,
outp: Q
) -> Result<HashMap<String, StorageT>, Box<dyn Error>> where
P: AsRef<Path>,
Q: AsRef<Path>, [src]
&mut self,
inp: P,
outp: Q
) -> Result<HashMap<String, StorageT>, Box<dyn Error>> where
P: AsRef<Path>,
Q: AsRef<Path>,
Statically compile the Yacc file inp into Rust, placing the output into the file outp.
Note that three additional files will be created with the same name as outp but with the
extensions grm, sgraph, and stable, overwriting any existing files with those names.
outp defines a module with the following functions:
fn parse(lexemes: &Vec<Lexeme<StorageT>>)
-> (Option<ActionT>, Vec<LexParseError<StorageT>>)>
fn token_epp<'a>(tidx: TIdx<StorageT>) -> Option<&'a str>
Where ActionT is either:
- the
%actiontypevalue given to the grammar - or, if the
yacckindwas set YaccKind::Original(YaccOriginalActionKind::UserAction), it isNode<StorageT>
Panics
If StorageT is not big enough to index the grammar's tokens, rules, or
productions.
Auto Trait Implementations
impl<StorageT> Send for CTParserBuilder<StorageT> where
StorageT: Send,
StorageT: Send,
impl<StorageT> Sync for CTParserBuilder<StorageT> where
StorageT: Sync,
StorageT: Sync,
Blanket Implementations
impl<T> From for T[src]
impl<T, U> Into for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T> Borrow for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T, U> TryInto for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
U: TryFrom<T>,