Skip to content

Commit

Permalink
Merge pull request #18 from SHADE-AI/fix/provinces-grammar
Browse files Browse the repository at this point in the history
fix: add coasts to province
  • Loading branch information
byung-o authored Sep 8, 2022
2 parents 56705b6 + 97f83af commit c81e27d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions daidepp/parser/grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down
8 changes: 8 additions & 0 deletions daidepp/parser/node_visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit c81e27d

Please sign in to comment.