pyebnf/compiler.py
def _get_rule_transform(self, rule):
    """The return value for each rule can be either retyped, compressed or left alone. This method
    determines that and returns the source code text for accomplishing it.
    """
    rd = self._find_directive(lambda d: d.name == "rule" and d.args.get("name") == rule.name)

    if rd:
      args = rd.args
    else:
      args = {}

    transform = args.get("transform", "retype")

    if transform == "retype":
      new_name = args.get("to_type", "TokenType.{0}".format(rule.name))
      return ".retyped({0})".format(new_name)
    elif transform == "compress":
      new_name = args.get("to_type", "TokenType.{0}".format(rule.name))
      if new_name == "identity":
        return ".compressed()"
      else:
        return ".compressed({0})".format(new_name)
    elif transform == "identity":
      return ""
def _get_rule_transform(self, rule):
    """The return value for each rule can be either retyped, compressed or left alone. This method
    determines that and returns the source code text for accomplishing it.
    """
    rd = self._find_directive(lambda d: d.name == "rule" and d.args.get("name") == rule.name)

    if rd:
      args = rd.args
    else:
      args = {}

    transform = args.get("transform", "retype")

    if transform == "retype":
      new_name = args.get("to_type", "TokenType.{0}".format(rule.name))
      return ".retyped({0})".format(new_name)
    elif transform == "compress":
      new_name = args.get("to_type", "TokenType.{0}".format(rule.name))
      if new_name == "identity":
        return ".compressed()"
      else:
        return ".compressed({0})".format(new_name)
    elif transform == "identity":
      return ""
def _get_rule_transform ( self , rule ) : rd = self . _find_directive ( lambda d : d . name == "rule" and d . args . get ( "name" ) == rule . name ) if rd : args = rd . args else : args = { } transform = args . get ( "transform" , "retype" ) if transform == "retype" : new_name = args . get ( "to_type" , "TokenType.{0}" . format ( rule . name ) ) return ".retyped({0})" . format ( new_name ) elif transform == "compress" : new_name = args . get ( "to_type" , "TokenType.{0}" . format ( rule . name ) ) if new_name == "identity" : return ".compressed()" else : return ".compressed({0})" . format ( new_name ) elif transform == "identity" : return ""
The return value for each rule can be either retyped, compressed or left alone. This method
    determines that and returns the source code text for accomplishing it.
The return value for each rule can be either retyped compressed or left alone . This method determines that and returns the source code text for accomplishing it .