Skip to content

Commit

Permalink
Update AScript: re-implement optional struct members
Browse files Browse the repository at this point in the history
  • Loading branch information
acweathersby committed Oct 30, 2024
1 parent 7b0c101 commit d8b653b
Show file tree
Hide file tree
Showing 5 changed files with 427 additions and 418 deletions.
14 changes: 7 additions & 7 deletions crates/cli/bin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub fn command() -> ArgMatches {
.required(false)
))
.subcommand(
Command::new("build-ast").about("Output an ast file from a gramamr and an @@ ast script")
Command::new("build-ast").about("Output an ast file from a grammar and an *.atat ast script")
.arg(
arg!( -a --atat <OUTPUT_PATH> "@@ ast script" )
.required(true)
Expand Down Expand Up @@ -130,16 +130,14 @@ fn main() -> RadlrResult<()> {
} else if let Some(matches) = matches.subcommand_matches("lab-mode") {
run_lab_server(matches.get_one::<u16>("port").cloned())
} else if let Some(matches) = matches.subcommand_matches("build-ast") {
process_atat_script(matches, pwd)
process_atat_script(matches)
} else {
RadlrResult::Err(RadlrError::from("Command Not Recognized"))
}
}

fn process_atat_script(matches: &ArgMatches, pwd: PathBuf) -> Result<(), RadlrError> {
let (_, out_dir, _lib_out_dir) = configure_matches(matches, &pwd);
fn process_atat_script(matches: &ArgMatches) -> Result<(), RadlrError> {
let grammar_sources = matches.get_many::<PathBuf>("INPUTS").unwrap_or_default().cloned().collect::<Vec<_>>();
let name = matches.get_one::<String>("name").cloned();

let atat_path = matches.get_one::<PathBuf>("atat").cloned().unwrap_or_default();
let atat_path = atat_path.canonicalize().expect("Could not resolve path to {atat_path}");
Expand All @@ -161,8 +159,10 @@ fn process_atat_script(matches: &ArgMatches, pwd: PathBuf) -> Result<(), RadlrEr
//// let parser = OpenOptions::new().append(false).truncate(true).write(true).create(true).open(&ast_path)?;

let buf = BufWriter::new(Vec::new());
let buf = adb.format(atat_script.as_str(), buf, 100, "ast_struct_name", &[])?;
println!("-------------------\n\n{}\n\n-------------------", String::from_utf8(buf.into_inner().expect("Could not read buffer bytes"))?);

let buf = adb.format(atat_script.as_str(), buf, 100, "ast_struct_name", &[("RUST_NODE_WRAPPER", "std::sync::Arc")])?;

println!("{}", String::from_utf8(buf.into_inner().expect("Could not read buffer bytes"))?);
};

//println!("Hello World {atat_script:?} {db:#?}");
Expand Down
Loading

0 comments on commit d8b653b

Please sign in to comment.