How to handle Print(B1 -> Tc1 | B2 -> Tc2 | B3)? First we have write the code to solve B1 -> Tc1 | Tc2 type conditional checks. When we have to deal with this, the first way we have coded does not work as there is a right parenthesis ')'.
def _parse_Tc(self):
b_node = self._parse_B()
if self.current_token.type == 'OPERATOR' and self.current_token.value == '->':
self._advance()
tc1_node = self._parse_Tc()
self._expect('OPERATOR', '|')
tc2_node = self._parse_Tc()
return Node('->', children=[b_node, tc1_node, tc2_node])
else:
return b_node
How to handle Print(B1 -> Tc1 | B2 -> Tc2 | B3)? First we have write the code to solve B1 -> Tc1 | Tc2 type conditional checks. When we have to deal with this, the first way we have coded does not work as there is a right parenthesis ')'.
def _parse_Tc(self):
b_node = self._parse_B()
if self.current_token.type == 'OPERATOR' and self.current_token.value == '->':
self._advance()
tc1_node = self._parse_Tc()
self._expect('OPERATOR', '|')
tc2_node = self._parse_Tc()
return Node('->', children=[b_node, tc1_node, tc2_node])
else:
return b_node