pyrser/parsing/base.py
def eval_rule(self, name: str) -> Node:
        """Evaluate a rule by name."""
        # context created by caller
        n = Node()
        id_n = id(n)
        self.rule_nodes['_'] = n
        self.id_cache[id_n] = '_'
        # TODO: other behavior for  empty rules?
        if name not in self.__class__._rules:
            self.diagnostic.notify(
                error.Severity.ERROR,
                "Unknown rule : %s" % name,
                error.LocationInfo.from_stream(self._stream, is_error=True)
            )
            raise self.diagnostic
        self._lastRule = name
        rule_to_eval = self.__class__._rules[name]
        # TODO: add packrat cache here, same rule - same pos == same res
        res = rule_to_eval(self)
        if res:
            res = self.rule_nodes['_']
        return res
def eval_rule(self, name: str) -> Node:
        """Evaluate a rule by name."""
        # context created by caller
        n = Node()
        id_n = id(n)
        self.rule_nodes['_'] = n
        self.id_cache[id_n] = '_'
        # TODO: other behavior for  empty rules?
        if name not in self.__class__._rules:
            self.diagnostic.notify(
                error.Severity.ERROR,
                "Unknown rule : %s" % name,
                error.LocationInfo.from_stream(self._stream, is_error=True)
            )
            raise self.diagnostic
        self._lastRule = name
        rule_to_eval = self.__class__._rules[name]
        # TODO: add packrat cache here, same rule - same pos == same res
        res = rule_to_eval(self)
        if res:
            res = self.rule_nodes['_']
        return res
def eval_rule ( self , name : str ) -> Node : # context created by caller n = Node ( ) id_n = id ( n ) self . rule_nodes [ '_' ] = n self . id_cache [ id_n ] = '_' # TODO: other behavior for  empty rules? if name not in self . __class__ . _rules : self . diagnostic . notify ( error . Severity . ERROR , "Unknown rule : %s" % name , error . LocationInfo . from_stream ( self . _stream , is_error = True ) ) raise self . diagnostic self . _lastRule = name rule_to_eval = self . __class__ . _rules [ name ] # TODO: add packrat cache here, same rule - same pos == same res res = rule_to_eval ( self ) if res : res = self . rule_nodes [ '_' ] return res
Evaluate a rule by name.
Evaluate a rule by name .