2021-07-03 01:37:27 +00:00
|
|
|
use engine_q::{ParserWorkingSet, Signature, SyntaxShape};
|
2021-06-30 01:42:56 +00:00
|
|
|
|
|
|
|
fn main() -> std::io::Result<()> {
|
|
|
|
if let Some(path) = std::env::args().nth(1) {
|
|
|
|
let mut working_set = ParserWorkingSet::new(None);
|
|
|
|
|
2021-07-01 22:40:08 +00:00
|
|
|
let sig = Signature::build("foo").named("--jazz", SyntaxShape::Int, "jazz!!", Some('j'));
|
|
|
|
working_set.add_decl((b"foo").to_vec(), sig);
|
|
|
|
|
2021-07-07 22:55:46 +00:00
|
|
|
let sig =
|
|
|
|
Signature::build("where").required("cond", SyntaxShape::RowCondition, "condition");
|
|
|
|
working_set.add_decl((b"where").to_vec(), sig);
|
|
|
|
|
|
|
|
let sig = Signature::build("if")
|
|
|
|
.required("cond", SyntaxShape::RowCondition, "condition")
|
|
|
|
.required("then_block", SyntaxShape::Block, "then block")
|
|
|
|
.required(
|
|
|
|
"else",
|
|
|
|
SyntaxShape::Literal(b"else".to_vec()),
|
|
|
|
"else keyword",
|
|
|
|
)
|
|
|
|
.required("else_block", SyntaxShape::Block, "else block");
|
|
|
|
working_set.add_decl((b"if").to_vec(), sig);
|
|
|
|
|
2021-07-08 06:19:38 +00:00
|
|
|
let sig = Signature::build("let")
|
|
|
|
.required("var_name", SyntaxShape::Variable, "variable name")
|
|
|
|
.required("=", SyntaxShape::Literal(b"=".to_vec()), "equals sign")
|
|
|
|
.required(
|
|
|
|
"value",
|
|
|
|
SyntaxShape::Expression,
|
|
|
|
"the value to set the variable to",
|
|
|
|
);
|
|
|
|
working_set.add_decl((b"let").to_vec(), sig);
|
|
|
|
|
2021-07-05 22:58:56 +00:00
|
|
|
//let file = std::fs::read(&path)?;
|
|
|
|
//let (output, err) = working_set.parse_file(&path, file);
|
|
|
|
let (output, err) = working_set.parse_source(path.as_bytes());
|
|
|
|
println!("{:#?}", output);
|
2021-07-02 06:44:37 +00:00
|
|
|
println!("error: {:?}", err);
|
2021-07-03 03:35:15 +00:00
|
|
|
// println!("{}", size_of::<Statement>());
|
|
|
|
|
|
|
|
// let mut buffer = String::new();
|
|
|
|
// let stdin = std::io::stdin();
|
|
|
|
// let mut handle = stdin.lock();
|
|
|
|
|
|
|
|
// handle.read_to_string(&mut buffer)?;
|
2021-06-30 01:42:56 +00:00
|
|
|
|
|
|
|
Ok(())
|
|
|
|
} else {
|
|
|
|
println!("specify file to lex");
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|