rust/crates/ra_parser/src
bors[bot] ce694ae118 Merge #1328
1328: Change TokenSource to iteration based r=matklad a=edwin0cheng

This PR change the `TokenSource` trait from random access to be an iteration based trait:
```rust

/// `TokenSource` abstracts the source of the tokens parser operates one.
///
/// Hopefully this will allow us to treat text and token trees in the same way!
pub trait TokenSource {
    fn current(&self) -> Token;

    /// Lookahead n token
    fn lookahead_nth(&self, n: usize) -> Token;

    /// bump cursor to next token
    fn bump(&mut self);

    /// Is the current token a specified keyword?
    fn is_keyword(&self, kw: &str) -> bool;
}

/// `TokenCursor` abstracts the cursor of `TokenSource` operates one.
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub struct Token {
    /// What is the current token?
    pub kind: SyntaxKind,

    /// Is the current token joined to the next one (`> >` vs `>>`).
    pub is_jointed_to_next: bool,
}
```

Note that the refactoring based on this new trait will be separated to incoming PRs

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-05-27 07:28:13 +00:00
..
grammar reformat 2019-05-24 01:48:44 +03:00
syntax_kind fixed macro for brackets 2019-05-15 12:34:48 +03:00
event.rs apply T! macro where it is possible 2019-05-15 15:35:47 +03:00
grammar.rs apply T! macro where it is possible 2019-05-15 15:35:47 +03:00
lib.rs Change TokenSource to iteration based 2019-05-25 20:41:03 +08:00
parser.rs Change TokenSource to iteration based 2019-05-25 20:41:03 +08:00
syntax_kind.rs Implemented T! macro for syntax kinds 2019-05-13 15:19:57 +03:00
token_set.rs docs 2019-02-21 15:24:42 +03:00