#[non_exhaustive]pub enum Rule {
LineComment(&'static str),
Block {
open: &'static str,
close: &'static str,
kind: u8,
nested: bool,
bol: bool,
},
Str {
open: &'static str,
close: &'static str,
escape: bool,
multi: bool,
kind: u8,
},
RawStr,
Interp {
open: &'static str,
close: &'static str,
start: &'static str,
},
Words(&'static [&'static str], u8),
Number,
Custom(fn(&str, usize, bool) -> Option<(usize, u8)>),
Punct(&'static str),
}Expand description
a rule of a grammar (see the module header)
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
LineComment(&'static str)
from the text to the end of the line: a comment
Block
from open to close (nested: opens inside count; bol: open and close only at the start of a line, after blanks – the whole line belongs to it); may span lines
Str
a string from open to close; escape: a backslash takes the next character (SY_ESCAPE); multi: may span lines
RawStr
Rust raw strings: r“..“, r#”..“#, br”..“ (may span lines)
Interp
a string with code inside (interpolation), on one line: from open to close, a backslash
takes the next character (\u{..} its hex digits and brace; SY_ESCAPE); from start
(ending with ‘{’) to the ‘}’ that closes it (braces inside count) the grammar’s rules
highlight code, the two delimiters SY_META
Words(&'static [&'static str], u8)
identifiers of a list
Number
number literals: 12, 0x1F, 0b101, 0o17, 1_000, 1.5e-3, suffixes (u8, f32)
Custom(fn(&str, usize, bool) -> Option<(usize, u8)>)
a function of its own: (line, position, at the line start after blanks) -> (bytes, kind)
Punct(&'static str)
single characters