minor change

This commit is contained in:
JT 2021-07-03 07:30:03 +12:00
parent a91efc3cbd
commit d8bf48e692
2 changed files with 14 additions and 11 deletions

View file

@ -7,10 +7,10 @@ fn main() -> std::io::Result<()> {
let sig = Signature::build("foo").named("--jazz", SyntaxShape::Int, "jazz!!", Some('j')); let sig = Signature::build("foo").named("--jazz", SyntaxShape::Int, "jazz!!", Some('j'));
working_set.add_decl((b"foo").to_vec(), sig); working_set.add_decl((b"foo").to_vec(), sig);
//let file = std::fs::read(&path)?; let file = std::fs::read(&path)?;
//let (output, err) = working_set.parse_file(&path, &file); let (output, err) = working_set.parse_file(&path, &file);
let (output, err) = working_set.parse_source(path.as_bytes()); //let (output, err) = working_set.parse_source(path.as_bytes());
println!("{:#?}", output); println!("{}", output.len());
println!("error: {:?}", err); println!("error: {:?}", err);
Ok(()) Ok(())

View file

@ -98,7 +98,7 @@ impl Call {
pub enum Expr { pub enum Expr {
Int(i64), Int(i64),
Var(VarId), Var(VarId),
Call(Call), Call(Box<Call>),
Operator(Operator), Operator(Operator),
BinaryOp(Box<Expression>, Box<Expression>, Box<Expression>), //lhs, op, rhs BinaryOp(Box<Expression>, Box<Expression>, Box<Expression>), //lhs, op, rhs
Subexpression(Box<Block>), Subexpression(Box<Block>),
@ -418,7 +418,7 @@ impl ParserWorkingSet {
// FIXME: type unknown // FIXME: type unknown
( (
Expression { Expression {
expr: Expr::Call(call), expr: Expr::Call(Box::new(call)),
ty: Type::Unknown, ty: Type::Unknown,
span: span(spans), span: span(spans),
}, },
@ -997,13 +997,16 @@ mod tests {
assert!(err.is_none()); assert!(err.is_none());
assert!(block.len() == 1); assert!(block.len() == 1);
assert!(matches!(
block[0], match &block[0] {
Statement::Expression(Expression { Statement::Expression(Expression {
expr: Expr::Call(Call { decl_id: 0, .. }), expr: Expr::Call(call),
.. ..
}) }) => {
)); assert_eq!(call.decl_id, 0);
}
_ => panic!("not a call"),
}
} }
#[test] #[test]