mirror of
https://github.com/danbulant/rush
synced 2026-05-19 04:18:35 +00:00
parse indexes
This commit is contained in:
parent
8632f9e067
commit
333fd74db1
2 changed files with 36 additions and 12 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use chumsky::{error::{EmptyErr, Rich, Simple}, prelude::{any, choice, end, just, none_of, one_of, recursive}, text, IterParser, Parser};
|
||||
use chumsky::{error::{EmptyErr, Rich, Simple}, prelude::{any, choice, end, just, none_of, one_of, recursive, Recursive}, text, IterParser, Parser};
|
||||
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
@ -171,6 +171,37 @@ pub fn parse<'a>() -> impl Parser<'a, &'a str, Vec<Statement>, chumsky::extra::D
|
|||
string.map(Primitive::String),
|
||||
));
|
||||
|
||||
let group = expr.clone()
|
||||
.delimited_by(just('('), just(')'))
|
||||
.map(|v| Value::Group(v));
|
||||
|
||||
let value = choice((
|
||||
group,
|
||||
primitive.clone().map(Value::Primitive),
|
||||
// index.map(|i| Value::Primitive(Primitive::Index(i))),
|
||||
));
|
||||
|
||||
let index = value.clone()
|
||||
.foldl(
|
||||
value
|
||||
.clone()
|
||||
.padded_by(text::inline_whitespace())
|
||||
.delimited_by(just('['), just(']'))
|
||||
.repeated(),
|
||||
|value, index| Value::Primitive(Primitive::Index(Index {
|
||||
value: Box::new(value.clone()),
|
||||
index: Box::new(index)
|
||||
})));
|
||||
|
||||
let value = choice((
|
||||
index,
|
||||
value,
|
||||
));
|
||||
// let value = recursive(|newvalue: Recursive<dyn Parser<'_, &str, Value>>| {
|
||||
|
||||
// value
|
||||
// });
|
||||
|
||||
let bindable = primitive.clone().map(Bindable::Primitive);
|
||||
|
||||
let bindable_group = bindable
|
||||
|
|
@ -179,20 +210,11 @@ pub fn parse<'a>() -> impl Parser<'a, &'a str, Vec<Statement>, chumsky::extra::D
|
|||
.separated_by(just(","))
|
||||
.collect()
|
||||
.delimited_by(just('('), just(')'));
|
||||
|
||||
let group = expr.clone()
|
||||
.delimited_by(just('('), just(')'))
|
||||
.map(|v| Value::Group(v));
|
||||
|
||||
|
||||
let block = expr.clone()
|
||||
.or(empty.to(vec![]))
|
||||
.delimited_by(just('{'), just('}'));
|
||||
|
||||
let value = choice((
|
||||
group,
|
||||
primitive.map(Value::Primitive),
|
||||
));
|
||||
|
||||
let cmdname = value.clone()
|
||||
.and_is(choice((
|
||||
just("set"),
|
||||
|
|
|
|||
|
|
@ -15,4 +15,6 @@ loop {}
|
|||
return 1
|
||||
|
||||
break
|
||||
continue
|
||||
continue
|
||||
|
||||
return $thing[property]
|
||||
Loading…
Reference in a new issue