Struct netsblox_ast::ParserBuilder
source · [−]pub struct ParserBuilder { /* private fields */ }Expand description
Builder for Parser.
Implementations
sourceimpl ParserBuilder
impl ParserBuilder
sourcepub fn optimize(&mut self, value: bool) -> &mut Self
pub fn optimize(&mut self, value: bool) -> &mut Self
If true, the emitted syntax tree will be processed by static optimizations.
Defaults to false.
sourcepub fn omit_nonhat_scripts(&mut self, value: bool) -> &mut Self
pub fn omit_nonhat_scripts(&mut self, value: bool) -> &mut Self
If true, the parser will skip script blocks that lack a hat block.
This is typically desirable since free floating blocks are never automatically executed,
and thus are typically not needed for translation efforts.
Defaults to true.
sourcepub fn adjust_to_zero_index(&mut self, value: bool) -> &mut Self
pub fn adjust_to_zero_index(&mut self, value: bool) -> &mut Self
If true, the emitted syntax tree will be automatically adjusted to support
convenient translation into languages with zero-based indexing.
For instance, with this enabled, an item X of _ block will emit X-1 as the index rather than X, and similar for other list-based blocks.
Defaults to false.
sourcepub fn name_transformer(
&mut self,
value: Rc<dyn Fn(&str) -> Result<String, ()>>
) -> &mut Self
pub fn name_transformer(
&mut self,
value: Rc<dyn Fn(&str) -> Result<String, ()>>
) -> &mut Self
All symbol names in the program will be passed through this function,
allowing easy conversion of Snap! names to, e.g., valid C-like identifiers.
The default operation performs no conversion.
Note that non-default transform strategies may also require a custom ParserBuilder::autofill_generator.
sourcepub fn autofill_generator(
&mut self,
value: Rc<dyn Fn(usize) -> Result<String, ()>>
) -> &mut Self
pub fn autofill_generator(
&mut self,
value: Rc<dyn Fn(usize) -> Result<String, ()>>
) -> &mut Self
A generator used to produce symbol names for auto-fill closure arguments.
The function receives a number that can be used to differentiate different generated arguments.
It is expected that multiple calls to this function with the same input will produce the same output symbol name.
The default is to produce a string of format %n where n is the input number.
Note that, after generation, symbol names are still passed through ParserBuilder::name_transformer as usual.
Trait Implementations
sourceimpl Clone for ParserBuilder
impl Clone for ParserBuilder
sourcefn clone(&self) -> ParserBuilder
fn clone(&self) -> ParserBuilder
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
Auto Trait Implementations
impl !RefUnwindSafe for ParserBuilder
impl !Send for ParserBuilder
impl !Sync for ParserBuilder
impl Unpin for ParserBuilder
impl !UnwindSafe for ParserBuilder
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more