properly lex $

This commit is contained in:
ConnorSkees 2020-03-21 14:20:33 -04:00
parent f88b4af564
commit 11a93a21a6

View File

@ -281,14 +281,17 @@ impl<'a> Lexer<'a> {
self.buf.next(); self.buf.next();
self.pos.next_char(); self.pos.next_char();
let mut name = String::with_capacity(99); let mut name = String::with_capacity(99);
if let Some(c) = self.buf.next() { if let Some(c) = self.buf.peek() {
if !c.is_alphabetic() && c != '-' && c != '_' { if c == &'=' {
return TokenKind::Symbol(Symbol::Dollar);
} else if !c.is_alphabetic() && c != &'-' && c != &'_' {
eprintln!("Error: Expected identifier."); eprintln!("Error: Expected identifier.");
std::process::exit(1) std::process::exit(1)
} else { } else {
self.pos.next_char(); self.pos.next_char();
name.push(c); name.push(*c);
} }
self.buf.next();
} }
while let Some(c) = self.buf.peek() { while let Some(c) = self.buf.peek() {
if !c.is_alphanumeric() && c != &'-' && c != &'_' { if !c.is_alphanumeric() && c != &'-' && c != &'_' {