Skip to content

Commit 2bccaba

Browse files
author
zleyyij
committed
partial language translation stuff
1 parent 098bdbf commit 2bccaba

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

.DS_Store

0 Bytes
Binary file not shown.

src/scripts/parser/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ tinyvec = { version = "1", features = ["alloc"]}
1616
indexmap = "2"
1717
encoding = "0.2"
1818
nom = "7.1.3"
19+
zstd = { version = "0.13.1", features = ["wasm"] }
20+
color-eyre = "0.6.3"

src/scripts/parser/src/lexer.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33

44
pub mod lexer {
55
use nom::branch::alt;
6-
use nom::bytes::complete::{is_not, take_till};
6+
use nom::bytes::complete::is_not;
77
use nom::character::complete::char as nom_char;
8-
use nom::combinator::eof;
98
use nom::{
109
bytes::complete::{tag, take_until},
1110
multi::many0,
@@ -40,7 +39,10 @@ pub mod lexer {
4039
///
4140
/// * `input` - A string slice from a csv generated by HWInfo.
4241
fn read_record(input: &str) -> IResult<&str, Vec<&str>> {
43-
let record: (&str, &str) = terminated(alt((take_until("\n"), is_not(""))), alt((tag("\n"), take_until(""))))(input)?;
42+
let record: (&str, &str) = terminated(
43+
alt((take_until("\n"), is_not(""))),
44+
alt((tag("\n"), take_until(""))),
45+
)(input)?;
4446
// apply the parser a bunch of times, until the input string is empty
4547
let record_parsing_output = many0(read_field)(record.1)?;
4648
// I want this function to integrate smoothly and behave like an idiomatic nom function

src/scripts/parser/src/lib.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
#![allow(soft_unstable)]
2-
// #![feature(test)]
2+
mod lang;
3+
mod lexer;
4+
mod parser;
5+
36
use encoding::{all::ISO_8859_1, Encoding};
47
use lexer::lexer::lex_csv;
58
use parser::parser::deserialize_csv;
69
use std::borrow::Cow;
710
use std::collections::HashMap;
811
use wasm_bindgen::prelude::*;
9-
mod lexer;
10-
mod parser;
1112

1213
// the same function as parse_csv, but with some wasm glue code around it
1314
#[wasm_bindgen(js_name = parse_csv)]
@@ -93,7 +94,10 @@ mod tests {
9394
horizontally_merged_spreadsheet.push(output_string);
9495
}
9596

96-
(horizontally_merged_spreadsheet.join("\n") + "\n", map_equivalent)
97+
(
98+
horizontally_merged_spreadsheet.join("\n") + "\n",
99+
map_equivalent,
100+
)
97101
}
98102

99103
#[test]
@@ -109,7 +113,7 @@ mod tests {
109113
#[test]
110114
fn parse_csv_from_file() {
111115
// TODO
112-
let mut file_handle = File::open("/Users/arc/Downloads/log11.csv").unwrap();
116+
let mut file_handle = File::open("/Users/arc/Downloads/asd.csv").unwrap();
113117
let mut file_vec = Vec::new();
114118
file_handle.read_to_end(&mut file_vec).unwrap();
115119
parse_csv(&file_vec);

0 commit comments

Comments
 (0)