Pass test
This commit is contained in:
parent
bff5ba81a3
commit
37a88df613
@ -44,9 +44,10 @@ pub fn lexer<'src>() -> impl Parser<
|
||||
Vec<(Token<'src>, SimpleSpan<usize>)>,
|
||||
extra::Err<Rich<'src, char, SimpleSpan<usize>>>,
|
||||
> {
|
||||
let boolean = just("true")
|
||||
.or(just("false"))
|
||||
.map(|s: &str| Token::Boolean(s.parse().unwrap()));
|
||||
let boolean = choice((
|
||||
just("true").padded().to(Token::Boolean(true)),
|
||||
just("false").padded().to(Token::Boolean(false)),
|
||||
));
|
||||
|
||||
let float_numeric = just('-')
|
||||
.or_not()
|
||||
|
@ -164,7 +164,7 @@ pub fn parser<'src>() -> DustParser<'src> {
|
||||
|
||||
let block = statement
|
||||
.clone()
|
||||
.separated_by(just(Token::Control(";")).or_not())
|
||||
.repeated()
|
||||
.collect()
|
||||
.delimited_by(just(Token::Control("{")), just(Token::Control("}")))
|
||||
.map(|statements| Statement::Block(Block::new(statements)))
|
||||
@ -172,7 +172,7 @@ pub fn parser<'src>() -> DustParser<'src> {
|
||||
|
||||
let r#loop = statement
|
||||
.clone()
|
||||
.separated_by(just(Token::Control(";")).or_not())
|
||||
.repeated()
|
||||
.collect()
|
||||
.delimited_by(
|
||||
just(Token::Keyword("loop")).then(just(Token::Control("{"))),
|
||||
@ -182,6 +182,7 @@ pub fn parser<'src>() -> DustParser<'src> {
|
||||
.boxed();
|
||||
|
||||
choice((assignment, expression_statement, block, r#loop))
|
||||
.then_ignore(just(Token::Control(";")).or_not())
|
||||
});
|
||||
|
||||
statement
|
||||
|
@ -2,8 +2,5 @@ use dust_lang::*;
|
||||
|
||||
#[test]
|
||||
fn set_and_get_variable() {
|
||||
assert_eq!(
|
||||
interpret("foobar = true foobar"),
|
||||
Ok(Value::boolean(true))
|
||||
);
|
||||
assert_eq!(interpret("foobar = true; foobar"), Ok(Value::boolean(true)));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user