Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
uses: dtolnay/rust-toolchain@nightly
- name: Install alsa and udev
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
if: runner.os == 'linux'
Expand Down
88 changes: 82 additions & 6 deletions src/builtin_parser/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -675,19 +675,95 @@ fn parse_object(

#[cfg(test)]
mod tests {
use logos::Span;

use crate::builtin_parser::Spanned;

use super::super::lexer::TokenStream;
use super::super::Environment;
use super::parse;
use super::{parse, Expression};

#[test]
fn var_assign() {
let mut lexer = TokenStream::new("x = 1 + 2 - 30 + y");
let environment = Environment::default();

let ast = parse(&mut lexer, &environment);

assert!(ast.is_ok());

// TODO: figure out how to assert ast
let ast = parse(&mut lexer, &environment).unwrap();

let mut stmts = ast.into_iter();

use crate::builtin_parser::parser::Operator::*;
use crate::builtin_parser::Number::*;
use Expression::*;

assert!(matches!(
stmts.next(),
Some(Spanned {
span: Span { start: 0, end: 18 },
value:
VarAssign {
name:
box Spanned {
span: Span { start: 0, end: 1 },
value: Variable(_),
},
value:
box Spanned {
span: Span { start: 4, end: 18 },
value:
BinaryOp {
left:
box Spanned {
span: Span { start: 4, end: 14 },
value:
BinaryOp {
left:
box Spanned {
span: Span { start: 4, end: 9 },
value:
BinaryOp {
left:
box Spanned {
span:
Span {
start: 4,
end: 5,
},
value:
Number(Integer(1)),
},
operator: Add,
right:
box Spanned {
span:
Span {
start: 8,
end: 9,
},
value:
Number(Integer(2)),
},
},
},
operator: Sub,
right:
box Spanned {
span: Span { start: 12, end: 14 },
value: Number(Integer(30)),
},
},
},
operator: Add,
right:
box Spanned {
span: Span { start: 17, end: 18 },
value: Variable(_),
},
},
},
},
})
));
// println!("{:#?}", stmts.next());
}
}
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![doc = include_str!("../README.md")]
#![cfg_attr(test, feature(box_patterns))]

use bevy::prelude::*;
use bevy_egui::EguiPlugin;
Expand Down