Struct rustdoc::html::highlight::Classifier [−][src]
pub struct Classifier<'a> { lexer: StringReader<'a>, codemap: &'a CodeMap, in_attribute: bool, in_macro: bool, in_macro_nonterminal: bool, }
Processes a program (nested in the internal lexer
), classifying strings of
text by highlighting category (Class
). Calls out to a Writer
to write
each span of text in sequence.
Fields
lexer: StringReader<'a>
codemap: &'a CodeMap
in_attribute: bool
in_macro: bool
in_macro_nonterminal: bool
Methods
impl<'a> Classifier<'a>
[src]
impl<'a> Classifier<'a>
pub fn new(lexer: StringReader<'a>, codemap: &'a CodeMap) -> Classifier<'a>
[src]
pub fn new(lexer: StringReader<'a>, codemap: &'a CodeMap) -> Classifier<'a>
fn try_next_token(&mut self) -> Result<TokenAndSpan>
[src]
fn try_next_token(&mut self) -> Result<TokenAndSpan>
Gets the next token out of the lexer, emitting fatal errors if lexing fails.
pub fn write_source<W: Writer>(&mut self, out: &mut W) -> Result<()>
[src]
pub fn write_source<W: Writer>(&mut self, out: &mut W) -> Result<()>
Exhausts the lexer
writing the output into out
.
The general structure for this method is to iterate over each token, possibly giving it an HTML span with a class specifying what flavor of token is used. All source code emission is done as slices from the source map, not from the tokens themselves, in order to stay true to the original source.
fn write_token<W: Writer>(
&mut self,
out: &mut W,
tas: TokenAndSpan
) -> Result<()>
[src]
fn write_token<W: Writer>(
&mut self,
out: &mut W,
tas: TokenAndSpan
) -> Result<()>
fn snip(&self, sp: Span) -> String
[src]
fn snip(&self, sp: Span) -> String
Auto Trait Implementations
impl<'a> !Send for Classifier<'a>
impl<'a> !Send for Classifier<'a>
impl<'a> !Sync for Classifier<'a>
impl<'a> !Sync for Classifier<'a>