Skip to content

Commit 31895fc

Browse files
authored
Merge ee0487e into 16920af
2 parents 16920af + ee0487e commit 31895fc

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Changelog file for dinero-rs project, a command line application for managing fi
44
## [0.21.0] - xxx
55
### Added
66
- Infer currency format from the journal file
7+
- ```isin``` is a valid property for commodities
78
### Changed
89
- Continuos integration pipeline is now better. No more problems like what happened between releases 0.18 and 0.20.
910
### Fixed

src/grammar/grammar.pest

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ directive = { include | price
1919
include = { "include" ~ws+ ~ glob ~ws*~end}
2020
glob = { string | (!end ~ ANY)* }
2121
price = {"P" ~ ws* ~ date ~ (ws ~ time)? ~ ws+ ~ commodity_in_directive ~ ws* ~number ~ ws* ~ commodity_in_directive ~ws* ~ comment? ~ end}
22-
commodity = { "commodity" ~ ws+ ~ commodity_in_directive ~ ws* ~ comment? ~ end ~
22+
commodity = { "commodity" ~ ws+ ~ commodity_spec ~ ws* ~ comment? ~ end ~
2323
(sep ~
2424
(
2525
comment
@@ -28,6 +28,7 @@ commodity = { "commodity" ~ ws+ ~ commodity_in_directive ~ ws* ~ comment? ~ end
2828
)?
2929
~end)*
3030
}
31+
commodity_spec = { string | (!";" ~!end ~ ANY)* }
3132
commodity_in_directive = { string | unquoted }
3233
payee_dir = { "payee" ~ ws+ ~ payee ~ ws* ~ comment? ~end ~
3334
(sep ~
@@ -54,7 +55,7 @@ account_dir = { "account" ~ ws+ ~ account ~ ws* ~ comment? ~ end ~
5455
)?
5556
~end)*
5657
}
57-
commodity_property = { (alias | note | format ) ~ ws+ ~ property_value }
58+
commodity_property = { (alias | note | format | isin) ~ ws+ ~ property_value }
5859
payee_property = { (alias | note) ~ ws+ ~ property_value }
5960
account_property = { (alias | payee_subdirective | check | assert | note | isin ) ~ ws+ ~ property_value }
6061
tag_property = { (check | assert) ~ ws+ ~ property_value }

src/parser/utils.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ pub(crate) fn parse_string(string: Pair<Rule>) -> String {
5959
quoted[1..len - 1].to_string()
6060
}
6161
Rule::unquoted => string.as_str().to_string(),
62+
Rule::commodity_spec => {
63+
let as_str = string.as_str();
64+
match string.into_inner().next() {
65+
Some(x) => parse_string(x),
66+
None => as_str.trim().to_string()
67+
}
68+
}
6269
Rule::currency | Rule::commodity_in_directive => {
6370
parse_string(string.into_inner().next().unwrap())
6471
}

0 commit comments

Comments
 (0)