diff --git a/daidepp/parser/grammar.py b/daidepp/parser/grammar.py index 94762d6..7b9a0ee 100644 --- a/daidepp/parser/grammar.py +++ b/daidepp/parser/grammar.py @@ -52,7 +52,7 @@ order = hld / mto / sup/ cvy / move_by_cvy / retreat / build hld = lpar unit rpar "HLD" mto = lpar unit rpar "MTO" ws province - sup = lpar unit rpar "SUP" lpar unit rpar ("MTO" ws prov_no_coast)? + sup = lpar unit rpar "SUP" lpar unit rpar ("MTO" ws province)? cvy = lpar unit rpar "CVY" lpar unit rpar "CTO" ws province move_by_cvy = lpar unit rpar "CTO" ws province ws "VIA" lpar prov_sea (ws prov_sea)* rpar retreat = rto / dsb @@ -66,7 +66,8 @@ unit_type = "AMY" / "FLT" unit = power ws unit_type ws province power = "AUS" / "ENG" / "FRA" / "GER" / "ITA" / "RUS" / "TUR" - province = prov_coast / prov_no_coast / prov_sea + province = prov_coast / prov_no_coast / prov_sea / (lpar prov_coast ws coast rpar) + coast = "NCS" / "ECS" / "SCS" / "WCS" prov_coast = "ALB" / "ANK" / "APU" / "ARM" / "BEL" / "BER" / "BRE" / "BUL" / "CLY" / "CON" / "DEN" / "EDI" / "FIN" / "GAS" / "GRE" / "HOL" / "KIE" / "LON" / "LVN" / "LVP" / "MAR" / "NAF" / "NAP" / "NWY" / "PIC" / "PIE" / "POR" / "PRU" / "ROM" / "RUM" / "SEV" / "SMY" / "SPA" / "STP" / "SWE" / "SYR" / "TRI" / "TUN" / "TUS" / "VEN" / "YOR" / "WAL" prov_no_coast = "BOH" / "BUD" / "BUR" / "MOS" / "MUN" / "GAL" / "PAR" / "RUH" / "SER" / "SIL" / "TYR" / "UKR" / "VIE" / "WAR" prov_sea = "ADR" / "AEG" / "BAL" / "BAR" / "BLA" / "BOT" / "EAS" / "ENG" / "HEL" / "ION" / "IRI" / "LYO" / "MAO" / "NAO" / "NTH" / "NWG" / "SKA" / "TYS" / "WES" diff --git a/daidepp/parser/node_visitor.py b/daidepp/parser/node_visitor.py index fa403c6..3a8d068 100644 --- a/daidepp/parser/node_visitor.py +++ b/daidepp/parser/node_visitor.py @@ -359,6 +359,14 @@ def visit_power(self, node, visited_children): return node.text def visit_province(self, node, visited_children): + if isinstance(visited_children[0], str): + return node.text + + _, province, _, coast, _ = visited_children[0] + + return province + " " + coast + + def visit_coast(self, node, visited_children): return node.text def visit_prov_coast(self, node, visited_children):