Skip to content

Commit

Permalink
Trying to solve everything for Rc mode, but still lifetime problems #52
Browse files Browse the repository at this point in the history
  • Loading branch information
mverleg committed May 29, 2018
1 parent ed26686 commit d3426ec
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
12 changes: 7 additions & 5 deletions src/mango/lexing/code_lexer.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![feature(nll)]

use mango::io::typ::Reader;
use mango::io::typ::ReaderResult::*;
use mango::lexing::string_lexer::StringLexer;
Expand Down Expand Up @@ -108,7 +110,7 @@ impl Lexer for CodeLexer {
panic!()
}
// This is a new line, so there may be indents.
return self.lex_indents(reader);
return self.lex_indents(&mut *reader);
}
if let Match(_) = reader.matches("\\n\\r?") {
// Newline WITHOUT line continuation.
Expand All @@ -122,7 +124,7 @@ impl Lexer for CodeLexer {
if let Match(_) = reader.matches("\\n\\r?") {
// If semicolon is followed by a newline (redundant), then we need to deal with indents (but ignore the newline itself).
// This will return the queue of tokens, including the semicolon.
return self.lex_indents(reader);
return self.lex_indents(&mut *reader);
}
// No newline, can just return the semicolon (which is certainly on the queue, and should be the only thing, but it is fine here if not).
return Token(self.buffer.pop().unwrap());
Expand Down Expand Up @@ -163,10 +165,10 @@ impl Lexer for CodeLexer {
}
}

fn get_reader(&self) -> &Rc<RefCell<Reader>> {
fn get_reader(&self) -> Rc<RefCell<Reader>> {
match self.reader_or_delegate {
ReaderOrDelegate::Reader(reader) => &reader,
ReaderOrDelegate::Delegate(delegate) => delegate.get_reader(),
ReaderOrDelegate::Reader(ref reader) => reader.clone(),
ReaderOrDelegate::Delegate(ref delegate) => delegate.get_reader(),
}
}
}
4 changes: 2 additions & 2 deletions src/mango/lexing/string_lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl Lexer for StringLexer {
}
}

fn get_reader(&self) -> &Rc<RefCell<Reader>> {
&self.reader
fn get_reader(&self) -> Rc<RefCell<Reader>> {
self.reader.clone()
}
}
2 changes: 1 addition & 1 deletion src/mango/lexing/typ.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ pub trait Lexer {
/// Every call to lex returns a token until the end of the input.
fn lex(&mut self) -> MaybeToken;

fn get_reader(&self) -> &Rc<RefCell<Reader>>;
fn get_reader(&self) -> Rc<RefCell<Reader>>;
}

0 comments on commit d3426ec

Please sign in to comment.