[][src]Struct rustc_parse::lexer::StringReader

pub struct StringReader<'a> {
    sess: &'a ParseSess,
    start_pos: BytePos,
    pos: BytePos,
    end_src_index: usize,
    src: Lrc<String>,
    override_span: Option<Span>,
}

Fields

sess: &'a ParseSessstart_pos: BytePos

Initial position, read-only.

pos: BytePos

The absolute offset within the source_map of the current character.

end_src_index: usize

Stop reading src at this index.

src: Lrc<String>

Source text to tokenize.

override_span: Option<Span>

Implementations

impl<'a> StringReader<'a>[src]

pub(crate) fn into_token_trees(
    self
) -> (PResult<'a, TokenStream>, Vec<UnmatchedBrace>)
[src]

impl<'a> StringReader<'a>[src]

pub fn new(
    sess: &'a ParseSess,
    source_file: Lrc<SourceFile>,
    override_span: Option<Span>
) -> Self
[src]

pub fn retokenize(sess: &'a ParseSess, span: Span) -> Self[src]

fn mk_sp(&self, lo: BytePos, hi: BytePos) -> Span[src]

pub fn next_token(&mut self) -> Token[src]

Returns the next token, including trivia like whitespace or comments.

fn fatal_span(&self, sp: Span, m: &str) -> FatalError[src]

Report a fatal lexical error with a given span.

fn err_span(&self, sp: Span, m: &str)[src]

Report a lexical error with a given span.

fn fatal_span_(&self, from_pos: BytePos, to_pos: BytePos, m: &str) -> FatalError[src]

Report a fatal error spanning [from_pos, to_pos).

fn err_span_(&self, from_pos: BytePos, to_pos: BytePos, m: &str)[src]

Report a lexical error spanning [from_pos, to_pos).

fn struct_fatal_span_char(
    &self,
    from_pos: BytePos,
    to_pos: BytePos,
    m: &str,
    c: char
) -> DiagnosticBuilder<'a>
[src]

fn cook_lexer_token(&self, token: TokenKind, start: BytePos) -> TokenKind[src]

Turns simple rustc_lexer::TokenKind enum into a rich librustc_ast::TokenKind. This turns strings into interned symbols and runs additional validation.

fn cook_lexer_literal(
    &self,
    start: BytePos,
    suffix_start: BytePos,
    kind: LiteralKind
) -> (LitKind, Symbol)
[src]

pub fn pos(&self) -> BytePos[src]

fn src_index(&self, pos: BytePos) -> usize[src]

fn str_from(&self, start: BytePos) -> &str[src]

Slice of the source text from start up to but excluding self.pos, meaning the slice does not include the character self.ch.

fn symbol_from(&self, start: BytePos) -> Symbol[src]

Creates a Symbol from a given offset to the current offset.

fn symbol_from_to(&self, start: BytePos, end: BytePos) -> Symbol[src]

As symbol_from, with an explicit endpoint.

fn str_from_to(&self, start: BytePos, end: BytePos) -> &str[src]

Slice of the source text spanning from start up to but excluding end.

fn forbid_bare_cr(&self, start: BytePos, s: &str, errmsg: &str)[src]

fn report_raw_str_error(&self, start: BytePos, opt_err: Option<RawStrError>)[src]

fn report_non_started_raw_string(&self, start: BytePos, bad_char: char) -> ![src]

fn report_unterminated_raw_string(
    &self,
    start: BytePos,
    n_hashes: usize,
    possible_offset: Option<usize>,
    found_terminators: usize
) -> !
[src]

fn report_too_many_hashes(&self, start: BytePos, found: usize) -> ![src]

Note: It was decided to not add a test case, because it would be to big. https://github.com/rust-lang/rust/pull/50296#issuecomment-392135180

fn validate_literal_escape(
    &self,
    mode: Mode,
    content_start: BytePos,
    content_end: BytePos
)
[src]

fn validate_int_literal(
    &self,
    base: Base,
    content_start: BytePos,
    content_end: BytePos
)
[src]

Auto Trait Implementations

impl<'a> !RefUnwindSafe for StringReader<'a>

impl<'a> !Send for StringReader<'a>

impl<'a> !Sync for StringReader<'a>

impl<'a> Unpin for StringReader<'a>

impl<'a> !UnwindSafe for StringReader<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.