52 lines
1.7 KiB
Rust
52 lines
1.7 KiB
Rust
mod visitor;
|
|
|
|
use std::fs;
|
|
use full_moon::parse;
|
|
|
|
use visitor::Visitor;
|
|
use visitor::ConstantFolder;
|
|
|
|
fn main() {
|
|
// let contents = fs::read_to_string("main_android_org.lua")
|
|
// let contents = fs::read_to_string("small.lua")
|
|
let contents = fs::read_to_string("very_small.lua")
|
|
.expect("Something went wrong reading the file");
|
|
|
|
let tree = parse(&contents).expect("Parsing lua gone wrong");
|
|
|
|
let mut folder = ConstantFolder::new();
|
|
folder.visit(tree);
|
|
|
|
// let nodes = tree.nodes_mut();
|
|
// for stmt in nodes.stmts() {
|
|
// match stmt {
|
|
// Stmt::LocalAssignment(_locals) => {
|
|
// // for name in locals.names() {
|
|
// // println!("name: {}", name)
|
|
// // }
|
|
// }
|
|
// Stmt::Assignment(assignment) => {
|
|
// for expr in assignment.expressions() {
|
|
// match expr {
|
|
// Expression::Value { value } => {
|
|
// match &**value {
|
|
// Value::Var(Var::Expression(ve)) => {
|
|
// println!("assign value var expression {}", ve.prefix());
|
|
// }
|
|
// Value::Var(Var::Name(name)) => {
|
|
// println!("assign value var name {}", name.token());
|
|
// }
|
|
// _ => {}
|
|
// }
|
|
// }
|
|
// _ => {}
|
|
// };
|
|
// }
|
|
// }
|
|
// _ => {
|
|
// // println!("stmt {}", stmt)
|
|
// }
|
|
// };
|
|
// }
|
|
}
|