Skip to content

Commit

Permalink
Trying to make delegated lexer compile but not yet #56
Browse files Browse the repository at this point in the history
  • Loading branch information
mverleg committed May 25, 2018
1 parent 03b152a commit 219463b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/mango/lexing/code_lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ enum ReaderOrDelegate {
}

impl ReaderOrDelegate {
fn end_delegation(&mut self) {
*self = match self {
ReaderOrDelegate::Delegate(delegate) => ReaderOrDelegate::Reader(delegate.consume()),
ReaderOrDelegate::Reader(reader) => ReaderOrDelegate::Reader(*reader),
fn end_delegation(self) -> Self {
use self::ReaderOrDelegate::*;
match self {
Delegate(delegate) => Reader(delegate.consume()),
read => read,
}
}
}
Expand Down Expand Up @@ -87,7 +88,7 @@ impl Lexer for CodeLexer {
}
// Code to stop delegation cannot be here, because `self` is still mutably borrowed through `delegate`
}
ReaderOrDelegate::Reader(mut reader) => {
ReaderOrDelegate::Reader(ref mut reader) => {
// todo: maybe this branch could be a separate function?

// If there is a buffer due to indentation or continuations, return from that.
Expand Down
1 change: 1 addition & 0 deletions src/mango/lexing/string_lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ impl StringLexer {

impl Lexer for StringLexer {
fn lex(&mut self) -> MaybeToken {
// TODO: perhaps there's a library that does parsing a string with escape characters
// TODO: doesn't handle escaping etc at all now
// TODO: this is going to have a problem if `matches` automatically eats whitespace
match self.reader.matches("[^\"\\n]*") {
Expand Down

0 comments on commit 219463b

Please sign in to comment.