Skip to content

Commit

Permalink
chore: updated daide_visitor and level 20 grammar with @byung-o
Browse files Browse the repository at this point in the history
  • Loading branch information
mjspeck committed Oct 5, 2022
1 parent 8f4ef02 commit b706e51
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
17 changes: 12 additions & 5 deletions src/daidepp/daide_visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,6 @@ def visit_wve(self, node, visited_children):
def visit_power(self, node, visited_children):
return node.text

def visit_province(self, node, visited_children):
return node.text

def visit_prov_coast(self, node, visited_children):
return node.text

Expand All @@ -440,9 +437,19 @@ def visit_unit_type(self, node, visited_children):
return node.text

def visit_province(self, node, visited_children):
if isinstance(visited_children[0], str):
if isinstance(visited_children, str):
return node.text
return visited_children[0][0].text
return visited_children[0]

def visit_prov_landlock(self, node, visited_children):
return node.text

def visit_prov_land_sea(self, node, visited_children):
return node.text

def visit_prov_coast(self, node, visited_children):
_, province, _, coast, _ = visited_children[0]
return province.text + " " + coast.text

def visit_coast(self, node, visited_children):
return node.text
Expand Down
9 changes: 1 addition & 8 deletions src/daidepp/grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,7 @@ def from_level(level: DAIDE_LEVEL, allow_just_arrangment: bool = False):
"unit_type": '"AMY" / "FLT"',
"unit": "power ws unit_type ws province",
"prov_no_coast": "prov_land_sea / prov_landlock / prov_sea",
"stp_ncs": 'lpar "STP" ws "SCS" rpar',
"stp_scs": 'lpar "STP" ws "SCS" rpar',
"spa_ncs": 'lpar "SPA" ws "NCS" rpar',
"spa_scs": 'lpar "SPA" ws "SCS" rpar',
"bul_ecs": 'lpar "BUL" ws "ECS" rpar',
"bul_scs": 'lpar "BUL" ws "SCS" rpar',
"prov_coast": "stp_ncs / stp_scs / spa_ncs / spa_scs / bul_ecs / bul_scs",
# "prov_coast": '"(STP NCS)" / "(STP SCS)" / "(SPA NCS)" / "(SPA SCS)" / "(BUL ECS)" / "(BUL SCS)"',
"prov_coast": '(lpar "STP" ws "SCS" rpar) / (lpar "STP" ws "SCS" rpar) / (lpar "SPA" ws "NCS" rpar) / (lpar "SPA" ws "SCS" rpar) / (lpar "BUL" ws "ECS" rpar) / (lpar "BUL" ws "SCS" rpar)',
"province": "prov_land_sea / prov_landlock / prov_sea / prov_coast",
"coast": '"NCS" / "ECS" / "SCS" / "WCS"',
"prov_land_sea": '"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"',
Expand Down

0 comments on commit b706e51

Please sign in to comment.