(if_, pred, else_, endif, match_if_true, match_if_false)
return ifelse
Constructs a parser for (possibly nested) if...(else)...endif blocks.
Constructs a parser for (possibly nested) if...(else)...endif blocks.
Constructs a parser for ( possibly nested ) if ... ( else ) ... endif blocks .
def _nested_if_else(if_, pred, else_, endif, match_if_true, match_if_false):
  """Constructs a parser for (possibly nested) if...(else)...endif blocks."""
  ifelse = pp.Forward()
  ifelse << pp.Group(  # pylint: disable=expression-not-assigned
      if_ +
      pred("predicate") +
      pp.ZeroOrMore(match_if_true | ifelse)("if_true") +
      pp.Optional(else_ +
                  pp.ZeroOrMore(match_if_false | ifelse)("if_false")) +
      endif)
  return ifelse
def _nested_if_else ( if_ , pred , else_ , endif , match_if_true , match_if_false ) : ifelse = pp . Forward ( ) ifelse << pp . Group ( # pylint: disable=expression-not-assigned if_ + pred ( "predicate" ) + pp . ZeroOrMore ( match_if_true | ifelse ) ( "if_true" ) + pp . Optional ( else_ + pp . ZeroOrMore ( match_if_false | ifelse ) ( "if_false" ) ) + endif ) return ifelse