diff --git a/.gitignore b/.gitignore index 96ef6c0..ea8c4bf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ /target -Cargo.lock diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index c69d7d3..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rust-analyzer.linkedProjects": [ - "./demo/Cargo.toml" - ] -} \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index e250776..d31d346 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,11 +1,8 @@ [package] -name = "renrs" -description = "A Rust-based visual novel backend compatible with Ren'Py .rpy script files." +name = "" version = "0.1.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -pest = "2.6.0" -pest_derive = "2.6.0" diff --git a/demo/.gitignore b/demo/.gitignore deleted file mode 100644 index ea8c4bf..0000000 --- a/demo/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/target diff --git a/demo/Cargo.toml b/demo/Cargo.toml deleted file mode 100644 index d2265c7..0000000 --- a/demo/Cargo.toml +++ /dev/null @@ -1,9 +0,0 @@ -[package] -name = "renrs-demo" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -renrs = { path = ".." } diff --git a/demo/demo.csv b/demo/demo.csv deleted file mode 100644 index 20a98c9..0000000 --- a/demo/demo.csv +++ /dev/null @@ -1,5 +0,0 @@ -65279,1179403647,1463895090 -3.1415927,2.7182817,1.618034 --40,-273.15 -13,42 -65537 diff --git a/demo/src/main.rs b/demo/src/main.rs deleted file mode 100644 index 79ef2ea..0000000 --- a/demo/src/main.rs +++ /dev/null @@ -1,5 +0,0 @@ -use renrs; - -fn main() { - renrs::parse("demo.csv"); -} diff --git a/src/csv.pest b/src/csv.pest deleted file mode 100644 index 8b94fc7..0000000 --- a/src/csv.pest +++ /dev/null @@ -1,9 +0,0 @@ -// + indicates one or more times -field = { (ASCII_DIGIT | "." | "-")+ } -// ~ indicates directly followed by -// * indicates zero or more times (optional) -record = { field ~ ("," ~ field)* } -// SOI - start of input -// END - end of input -// There may be trailing newlines at the end -file = { SOI ~ (record ~ ("\r\n" | "\n"))* ~ "\n"* ~ EOI } diff --git a/src/lib.rs b/src/lib.rs deleted file mode 100644 index 6b32541..0000000 --- a/src/lib.rs +++ /dev/null @@ -1,35 +0,0 @@ -use std::fs; - -use pest::Parser; -use pest_derive::Parser; - -#[derive(Parser)] -#[grammar = "csv.pest"] -struct CSVParser; - -pub fn parse(file_path: &str) { - let unparsed_file = fs::read_to_string(file_path).expect("cannot find file"); - let file = CSVParser::parse(Rule::file, &unparsed_file) - .expect("unsuccessful parse") // unwrap the parse result - .next().unwrap(); // get and unwrap the `file` rule; never fails - - let mut field_sum = 0.0; - let mut record_count: u64 = 0; - - for record in file.into_inner() { - match record.as_rule() { - Rule::record => { - record_count += 1; - - for field in record.into_inner() { - field_sum += field.as_str().parse::().unwrap(); - } - }, - Rule::EOI => (), - _ => unreachable!(), - } - } - - println!("Sum of fields: {field_sum}"); - println!("Number of records: {record_count}"); -} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +}