pdx-syntax 0.2.0

Paradox script/localization syntax parser.
Documentation
//! Syntax grammar for localization files.
//!
grammar;

use crate::localization::types::*;

match {  
    // white space
    r"\s*" => {},
    // line comment
    r"\#[^\n\r]*[\n\r]*" => {},
    // default (defined below)
    _
}

pub LocList: LocList = <lang: Loc> <entries: Entry+> => LocList{ <> };

Loc: Loc = <Ident> ":" => Loc(<>);

Entry: Entry = <key: Ident> ":" <num: Num?> <value: RawStr> => Entry{ <> };

Ident: String = r#"[a-zA-Z0-9_\-\.\']*"# => <>.to_string();
// Receive single line, even with '\"'.
RawStr: String = r#"\"[^\n\r]*\""# => <>.to_string();
Num: u8 = <Ident> => <>.parse::<u8>().unwrap();