Skip to content

Commit

Permalink
Merge ee0487e into 16920af
Browse files Browse the repository at this point in the history
  • Loading branch information
frosklis authored Mar 19, 2021
2 parents 16920af + ee0487e commit 31895fc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog file for dinero-rs project, a command line application for managing fi
## [0.21.0] - xxx
### Added
- Infer currency format from the journal file
- ```isin``` is a valid property for commodities
### Changed
- Continuos integration pipeline is now better. No more problems like what happened between releases 0.18 and 0.20.
### Fixed
Expand Down
5 changes: 3 additions & 2 deletions src/grammar/grammar.pest
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ directive = { include | price
include = { "include" ~ws+ ~ glob ~ws*~end}
glob = { string | (!end ~ ANY)* }
price = {"P" ~ ws* ~ date ~ (ws ~ time)? ~ ws+ ~ commodity_in_directive ~ ws* ~number ~ ws* ~ commodity_in_directive ~ws* ~ comment? ~ end}
commodity = { "commodity" ~ ws+ ~ commodity_in_directive ~ ws* ~ comment? ~ end ~
commodity = { "commodity" ~ ws+ ~ commodity_spec ~ ws* ~ comment? ~ end ~
(sep ~
(
comment
Expand All @@ -28,6 +28,7 @@ commodity = { "commodity" ~ ws+ ~ commodity_in_directive ~ ws* ~ comment? ~ end
)?
~end)*
}
commodity_spec = { string | (!";" ~!end ~ ANY)* }
commodity_in_directive = { string | unquoted }
payee_dir = { "payee" ~ ws+ ~ payee ~ ws* ~ comment? ~end ~
(sep ~
Expand All @@ -54,7 +55,7 @@ account_dir = { "account" ~ ws+ ~ account ~ ws* ~ comment? ~ end ~
)?
~end)*
}
commodity_property = { (alias | note | format ) ~ ws+ ~ property_value }
commodity_property = { (alias | note | format | isin) ~ ws+ ~ property_value }
payee_property = { (alias | note) ~ ws+ ~ property_value }
account_property = { (alias | payee_subdirective | check | assert | note | isin ) ~ ws+ ~ property_value }
tag_property = { (check | assert) ~ ws+ ~ property_value }
Expand Down
7 changes: 7 additions & 0 deletions src/parser/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ pub(crate) fn parse_string(string: Pair<Rule>) -> String {
quoted[1..len - 1].to_string()
}
Rule::unquoted => string.as_str().to_string(),
Rule::commodity_spec => {
let as_str = string.as_str();
match string.into_inner().next() {
Some(x) => parse_string(x),
None => as_str.trim().to_string()
}
}
Rule::currency | Rule::commodity_in_directive => {
parse_string(string.into_inner().next().unwrap())
}
Expand Down

0 comments on commit 31895fc

Please sign in to comment.