diff --git a/daidepp/parser/grammar.py b/daidepp/parser/grammar.py index 7b9a0ee..e2290b2 100644 --- a/daidepp/parser/grammar.py +++ b/daidepp/parser/grammar.py @@ -31,7 +31,7 @@ arrangement = pce / aly_vss / drw / slo / not / nar / xdo / dmz / and / orr / scd / occ / cho / for / xoy / ydo / snd / fwd / bcc pce = "PCE" lpar power (ws power)* rpar aly_vss = "ALY" lpar power (ws power)* rpar "VSS" lpar power (ws power)* rpar - drw = "DRW" + drw = "DRW" (lpar power (ws power)+ rpar)? slo = "SLO" lpar power rpar not = "NOT" lpar arrangement rpar nar = "NAR" lpar arrangement rpar diff --git a/daidepp/parser/node_visitor.py b/daidepp/parser/node_visitor.py index 3a8d068..02b4ae6 100644 --- a/daidepp/parser/node_visitor.py +++ b/daidepp/parser/node_visitor.py @@ -160,7 +160,19 @@ def visit_aly_vss(self, node, visited_children): return ("ALY_VSS", (aly_list, vss_list)) def visit_drw(self, node, visited_children): - return node.text + _, par_powers = visited_children + + if isinstance(par_powers, Node) and not par_powers.text: + return "DRW" + + # For Partial draws are allowed (PDA) variant game + _, power, ws_powers, _ = par_powers[0] + pow_list = [power] + for ws_pow in ws_powers: + _, pow = ws_pow + pow_list.append(pow) + + return ("DRW", pow_list) def visit_slo(self, node, visited_children): _, _, power, _ = visited_children