Make = a keyword
This commit is contained in:
parent
72b26755a7
commit
e870d8172a
@ -112,8 +112,7 @@ fn statement(tokens: &mut Tokens) -> ParseResult {
|
||||
fn let_expression(tokens: &mut Tokens) -> ParseResult {
|
||||
expect!(Keyword(Kw::Let), tokens);
|
||||
if let Some(&Identifier(ref name)) = tokens.next() {
|
||||
if let Some(&Identifier(ref s)) = tokens.next() {
|
||||
if s == "=" {
|
||||
if let Some(&Keyword(Kw::Assign)) = tokens.next() {
|
||||
if let Ok(expr) = expression(tokens) {
|
||||
return Ok(
|
||||
AST::Binding(name.clone(),
|
||||
@ -121,7 +120,6 @@ fn let_expression(tokens: &mut Tokens) -> ParseResult {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Err("Bad parse in let_expression()".to_string());
|
||||
}
|
||||
|
@ -21,7 +21,8 @@ pub enum Kw {
|
||||
End,
|
||||
Let,
|
||||
Fn,
|
||||
Null
|
||||
Null,
|
||||
Assign
|
||||
}
|
||||
|
||||
pub fn tokenize(input: &str) -> Vec<Token> {
|
||||
@ -106,6 +107,7 @@ fn handle_identifier(identifier: String) -> Token {
|
||||
"end" => Kw::End,
|
||||
"fn" => Kw::Fn,
|
||||
"null" => Kw::Null,
|
||||
"=" => Kw::Assign,
|
||||
_ => return Token::Identifier(identifier)
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user