Rust: make things compile

This commit is contained in:
Arthur Baars
2024-09-13 16:57:54 +02:00
parent fabdb3c841
commit 61ac8d66f5
4 changed files with 52 additions and 0 deletions

12
Cargo.lock generated
View File

@@ -684,6 +684,9 @@ checksum = "7ab85b9b05e3978cc9a9cf8fea7f01b494e1a09ed3037e16ba39edc7a29eb61a"
name = "generate-schema"
version = "0.1.0"
dependencies = [
"itertools 0.10.5",
"proc-macro2",
"quote",
"ungrammar",
]
@@ -856,6 +859,15 @@ version = "1.70.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
[[package]]
name = "itertools"
version = "0.10.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473"
dependencies = [
"either",
]
[[package]]
name = "itertools"
version = "0.12.1"

View File

@@ -0,0 +1,17 @@
pub mod grammar;
pub fn reformat(x: String) -> String {
x
}
pub fn add_preamble(_x: crate::flags::CodegenType, y: String) -> String {
y
}
pub fn ensure_file_contents(
_x: crate::flags::CodegenType,
path: &std::path::Path,
contents: &String,
_check: bool,
) {
std::fs::write(path, contents).expect("Unable to write file");
}

View File

@@ -0,0 +1,11 @@
use std::fmt::Display;
pub enum CodegenType {
Grammar,
}
impl Display for CodegenType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "Grammar")
}
}

View File

@@ -0,0 +1,12 @@
use std::path::PathBuf;
mod codegen;
mod flags;
use std::env;
fn project_root() -> PathBuf {
let dir =
env::var("CARGO_MANIFEST_DIR").unwrap_or_else(|_| env!("CARGO_MANIFEST_DIR").to_owned());
PathBuf::from(dir).parent().unwrap().to_owned()
}
fn main() {}