Skip to content

Commit

Permalink
add rgb
Browse files Browse the repository at this point in the history
  • Loading branch information
jzebedee committed Sep 4, 2020
1 parent 8d8ef66 commit 63c31f9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/ck3json/ck3parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ pub fn parse(ck3txt: &str) -> Result<JSONValue, Error<Rule>> {
use pest::iterators::Pair;
fn parse_value(pair: Pair<Rule>) -> JSONValue {
match pair.as_rule() {
Rule::object => JSONValue::Object(
Rule::rgb
| Rule::object => JSONValue::Object(
pair.into_inner()
.map(|pair| {
let mut inner_rules = pair.into_inner();
Expand All @@ -38,7 +39,7 @@ pub fn parse(ck3txt: &str) -> Result<JSONValue, Error<Rule>> {
| Rule::identifier
| Rule::pair
| Rule::value
| Rule::inner
| Rule::string_inner
| Rule::char
| Rule::int
| Rule::float
Expand Down
8 changes: 4 additions & 4 deletions src/grammars/ck3txt.pest
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ array = {
"{" ~ value* ~ "}"
}

value = _{ object | array | date | string | number | boolean | tag }
value = _{ object | array | rgb | date | string | number | boolean | tag }

boolean = @{ ("yes" | "no") ~ !ASCII_ALPHA }

string = ${ "\"" ~ inner ~ "\"" }
inner = @{ char* }
string = ${ "\"" ~ string_inner ~ "\"" }
string_inner = @{ char* }
char = {
!("\"" | "\\") ~ ANY
| "\\" ~ ("\"" | "\\" | "/" | "b" | "f" | "n" | "r" | "t")
Expand All @@ -31,7 +31,7 @@ number = @{ float | int }

int = @{"-"? ~ ASCII_DIGIT+}
float = @{int? ~ "." ~ ASCII_DIGIT+ ~ "f"?}

rgb = {"rgb" ~ array}
date = ${ ("\"" ~ date_inner ~ "\"") | date_inner }
date_inner = @{ASCII_DIGIT+ ~ "." ~ ASCII_DIGIT+ ~ "." ~ ASCII_DIGIT+ }

Expand Down

0 comments on commit 63c31f9

Please sign in to comment.