Struct snarkvm_console_collections::Sanitizer
pub struct Sanitizer;
Implementations§
§impl Sanitizer
impl Sanitizer
pub fn parse(string: &str) -> Result<(&str, &str), Err<VerboseError<&str>>>
pub fn parse(string: &str) -> Result<(&str, &str), Err<VerboseError<&str>>>
Removes all leading whitespaces and comments from the given input, returning the sanitized input.
pub fn parse_whitespaces(
string: &str
) -> Result<(&str, &str), Err<VerboseError<&str>>>
pub fn parse_whitespaces( string: &str ) -> Result<(&str, &str), Err<VerboseError<&str>>>
Removes leading whitespaces from the given input.
pub fn parse_comments(
string: &str
) -> Result<(&str, &str), Err<VerboseError<&str>>>
pub fn parse_comments( string: &str ) -> Result<(&str, &str), Err<VerboseError<&str>>>
Removes multiple leading comments from the given input.
pub fn parse_comment(
string: &str
) -> Result<(&str, &str), Err<VerboseError<&str>>>
pub fn parse_comment( string: &str ) -> Result<(&str, &str), Err<VerboseError<&str>>>
Removes the first leading comment from the given input.
pub fn parse_safe_char(
string: &str
) -> Result<(&str, char), Err<VerboseError<&str>>>
pub fn parse_safe_char( string: &str ) -> Result<(&str, char), Err<VerboseError<&str>>>
Parse a safe character (in the sense explained in [string_parser::is_char_supported]). Returns an error if no character is found or a non-safe character is found. The character is returned, along with the remaining input.
This is used for otherwise unconstrained characters in (line and block) comments and in string literals.
Note also that the nom
documentation for anychar
says that
it matches one byte as a character.
However, simple experiments show that it matches a Unicode character,
e.g. attempting to parse "\u{4141}"
yields one CJK character and exhausts the input,
as opposed to returning A
and leaving another A
in the input.