Skip to content

Commit

Permalink
major changes to parser, irgen, output
Browse files Browse the repository at this point in the history
Co-authored-by: Sasial <[email protected]>
  • Loading branch information
jackdotink and sasial-dev committed Dec 26, 2023
1 parent eec37cb commit e8b4223
Show file tree
Hide file tree
Showing 19 changed files with 1,696 additions and 1,025 deletions.
48 changes: 30 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
codespan-reporting = "0.11.0"
anyhow = "1.0"
clap = { version = "4.4.11", features = ["derive"] }
zap = { path = "../zap" }
Expand Down
50 changes: 36 additions & 14 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ use std::path::PathBuf;

use anyhow::Result;
use clap::Parser;
use codespan_reporting::{
files::SimpleFile,
term::{
self,
termcolor::{ColorChoice, StandardStream},
},
};
use zap::run;

#[derive(Parser, Debug)]
Expand All @@ -16,26 +23,41 @@ fn main() -> Result<()> {

let config_path = args.config.unwrap();

let config = std::fs::read_to_string(config_path)?;
let config = std::fs::read_to_string(&config_path)?;

let code = run(config.as_str())?;
let (code, diagnostics) = run(config.as_str());

if let Some(definitions) = code.server.definitions {
let mut path = code.server.path.clone();
path.set_extension("d.ts");
if let Some(code) = code {
if let Some(definitions) = code.server.definitions {
let mut path = code.server.path.clone();
path.set_extension("d.ts");

std::fs::write(path, definitions)?
}
std::fs::write(path, definitions)?
}

if let Some(definitions) = code.client.definitions {
let mut path = code.client.path.clone();
path.set_extension("d.ts");

if let Some(definitions) = code.client.definitions {
let mut path = code.client.path.clone();
path.set_extension("d.ts");
std::fs::write(path, definitions)?
}

std::fs::write(code.server.path, code.server.contents)?;
std::fs::write(code.client.path, code.client.contents)?;
}

std::fs::write(path, definitions)?
if diagnostics.is_empty() {
return Ok(());
}

std::fs::write(code.server.path, code.server.contents)?;
std::fs::write(code.client.path, code.client.contents)?;
let file = SimpleFile::new(config_path.to_str().unwrap(), config);

let writer = StandardStream::stderr(ColorChoice::Always);
let config_term = codespan_reporting::term::Config::default();

for diagnostic in diagnostics {
term::emit(&mut writer.lock(), &config_term, &file, &diagnostic)?;
}

Ok(())
todo!()
}
3 changes: 1 addition & 2 deletions zap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ lalrpop = "0.20.0"

[dependencies]
lalrpop-util = "0.20.0"
ariadne = "0.3.0"
codespan-reporting = "0.11.0"
logos = "0.13.0"
num-traits = "0.2.17"
thiserror = "1.0"
wasm-bindgen = "0.2"
6 changes: 6 additions & 0 deletions zap/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fn main() {
lalrpop::Configuration::new()
.set_in_dir("src/parser")
.process()
.unwrap();
}
Loading

0 comments on commit e8b4223

Please sign in to comment.