Struct netsblox_ast::Parser
source · pub struct Parser {
pub omit_nonhat_scripts: bool,
pub name_transformer: Rc<dyn Fn(&str) -> Result<String, ()>>,
pub autofill_generator: Rc<dyn Fn(usize) -> Result<String, ()>>,
}Fields§
§omit_nonhat_scripts: boolIf 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.
name_transformer: Rc<dyn Fn(&str) -> Result<String, ()>>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 Parser::autofill_generator.
autofill_generator: Rc<dyn Fn(usize) -> Result<String, ()>>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 Parser::name_transformer as usual.