-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add pta link to readme * create CI workflow * Initial code migrated from other project * Rm'd extraneous ledger module; minor edits * Add CLI to verify accessibility and for future impl * WIP: Cli parses basic ledger * Fix commodity directive * WIP: multiple comment tokens; CLI output * trans block parses * Refactor parser tests * add simple transactions to ledger file * Consolidate pest rules to simplify * WIP: consuming parser * Removed pest_consume * vscode settings * moving parse handling to builder; refactor cli to use it * WIP: LedgerBuilder, logging * Fix warnings * Begin multiple grammar support * v0.2.0 - multi-grammar support * pkg upgrades * Upgrade log to 0.4.21 & adapt warn macro * Rm warnings on unused workspace repos info --------- Co-authored-by: jburnett <[email protected]> Co-authored-by: jburnett <[email protected]>
- Loading branch information
1 parent
dd5bb83
commit 96d2452
Showing
22 changed files
with
1,368 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"rust-analyzer.linkedProjects": [ | ||
"./cli/Cargo.toml", | ||
"./pta-ledger/Cargo.toml", | ||
"./pta-parser/Cargo.toml", | ||
"./pta-types/Cargo.toml" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright (C) 2023, AltaModa Technologies, LLC. All rights reserved. | ||
# | ||
# This project is licensed under the terms of the MIT license (cf. LICENSE file in root). | ||
|
||
[workspace] | ||
resolver = "2" | ||
members = [ | ||
"cli" | ||
,"pta-ledger" | ||
,"pta-parser" | ||
,'pta-types', | ||
] | ||
|
||
# Default values for workspace projects | ||
[workspace.package] | ||
edition = "2021" | ||
version = "0.2.0" | ||
authors = ["AltaModa Technologies"] | ||
# respository = "https://github.com/altamodatech/pta-parser" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright (C) 2023, AltaModa Technologies, LLC. All rights reserved. | ||
# | ||
# This project is licensed under the terms of the MIT license (cf. LICENSE file in root). | ||
|
||
[package] | ||
name = "cli" | ||
version.workspace = true | ||
authors.workspace = true | ||
# respository.workspace = true | ||
edition.workspace = true | ||
|
||
|
||
[dependencies] | ||
log = "0.4.21" | ||
pest = "2.7.3" | ||
pretty_env_logger = "0.5.0" | ||
pta-ledger = { path = "../pta-ledger" } | ||
pta-parser = { path = "../pta-parser" } | ||
pta-types = { path = "../pta-types" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright (C) 2023, AltaModa Technologies, LLC. All rights reserved. | ||
// | ||
// This project is licensed under the terms of the MIT license (cf. LICENSE file in root). | ||
// | ||
|
||
extern crate pta_ledger; | ||
extern crate pta_parser; | ||
|
||
|
||
use log::{info, warn, error}; | ||
|
||
// TODO: how to isolate pest so clients can just use lib (w/o requiring pest as here) | ||
use pta_ledger::ledger_builder::LedgerBuilder; | ||
|
||
|
||
|
||
fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
// TODO: CLI improvements | ||
// - exec with path of file to parse | ||
// - optionally output parse results (should be equivalent to input file) | ||
|
||
// TODO: consider flag to use init_timed to include time per line | ||
pretty_env_logger::init(); | ||
|
||
let pb = std::env::current_dir()?; | ||
let p = pb.join("testdata/basic-ledger"); | ||
|
||
info!("Input file: {:?}", p); | ||
|
||
let mut bldr = LedgerBuilder::default(); | ||
match std::fs::read_to_string(p) { | ||
Ok(ledger) => { | ||
info!("String length from input: {}", ledger.len()); | ||
match bldr.from_string(&ledger) { | ||
Ok(_parsed) => { | ||
info!("Successfully parsed into ParsedLedger"); | ||
return Ok(()); | ||
}, | ||
|
||
Err(e) => { | ||
error!("LedgerBuilder failed with {:}", e); | ||
return Err(e); | ||
} | ||
} | ||
} | ||
|
||
Err(e) => { | ||
warn!("failed to read file as string; {e}"); | ||
return Err(Box::new(e)); | ||
} | ||
} | ||
|
||
} | ||
|
||
|
||
|
||
#[cfg(test)] | ||
mod cli_tests { | ||
|
||
use pta_parser::parsers::generic::Parser; | ||
|
||
#[test] | ||
fn can_create_parser() { | ||
// simply verifies that the parser can be instantiated, ensuring accessibility | ||
let _ = Parser{}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Plain-Text Accounting Parser | ||
|
||
## History | ||
|
||
### 10/18/2023 | ||
|
||
Abandonded effort to integrate [pest_consume](https://lib.rs/crates/pest_consume) since the author is no longer maintaining it. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright (C) 2023, AltaModa Technologies, LLC. All rights reserved. | ||
# | ||
# This project is licensed under the terms of the MIT license (cf. LICENSE file in root). | ||
|
||
[package] | ||
name = "pta-ledger" | ||
version.workspace = true | ||
authors.workspace = true | ||
# respository.workspace = true | ||
edition.workspace = true | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
[lib] | ||
bench = false | ||
|
||
[dependencies] | ||
log = { version = "0.4.20", features = ["kv_unstable", "kv_unstable_serde"] } | ||
pest = "2.7.3" | ||
pest_derive = "2.7.3" | ||
pta-parser = { path = "../pta-parser" } | ||
pta-types ={ path = "../pta-types" } | ||
|
||
[dev-dependencies] | ||
rstest = "0.19.0" |
Oops, something went wrong.