Introduced index notation
This commit is contained in:
parent
f3c3d4595e
commit
3911c45dde
@ -310,6 +310,9 @@ impl<'a> Evaluator<'a> {
|
||||
}
|
||||
}
|
||||
}
|
||||
Index(box expr, box index_expr) => {
|
||||
(Null, None)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,6 +72,7 @@ pub enum Expression {
|
||||
Lambda(Function),
|
||||
Block(VecDeque<Expression>),
|
||||
While(Box<Expression>, Vec<Expression>),
|
||||
Index(Box<Expression>, Box<Expression>),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
@ -402,7 +403,10 @@ impl Parser {
|
||||
}
|
||||
},
|
||||
Some(LSquareBracket) => {
|
||||
unimplemented!()
|
||||
expect!(self, LSquareBracket);
|
||||
let index_expr = self.expression()?;
|
||||
expect!(self, RSquareBracket);
|
||||
Index(Box::new(expr), Box::new(index_expr))
|
||||
},
|
||||
_ => {
|
||||
expr
|
||||
|
@ -120,7 +120,7 @@ fn tokenize_identifier(c: char, iter: &mut Peekable<Chars>) -> Result<Token, Tok
|
||||
fn ends_identifier(c: &char) -> bool {
|
||||
let c = *c;
|
||||
char::is_whitespace(c) || is_digit(&c) || c == ';' || c == '(' || c == ')' ||
|
||||
c == ',' || c == '.' || c == ',' || c == ':'
|
||||
c == ',' || c == '.' || c == ',' || c == ':' || c == '[' || c == ']'
|
||||
}
|
||||
|
||||
use self::Token::*;
|
||||
|
Loading…
Reference in New Issue
Block a user