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