예제 #1
0
    def fsm_char_pattern(cls, ch):
        """Return FSM character pattren registered within tokenizer.

        :Parameters:
            ch : str
                the FSM character
        :Note:

            If it doesn't exist, this method will create empty dictionary
            ``_fsm_char_patterns`` within ``cls`` subclass (as a class
            attribute).

        :Note:

            This method may throw exceptions in case the `ch` was not
            registered. For exception specification, see documentation of
            `ezmlex.patterns.pattern()`.
        """
        from ezmlex.patterns import pattern
        return pattern(cls.fsm_char_patterns(), ch)
예제 #2
0
    def pattern(cls, *args):
        """Return a helper pattern registered within tokenizer.

        :Parameters:
            args 
                arguments and their meaning are same as for
                `ezmlex.patterns.pattern()`,
                except that there must be no ``tab`` argument in 
                ``*args`` list, and the ``*args`` list must start from ``_id``.

        :Note:

            If it doesn't exist, this method will create empty dictionary
            ``_char_classes`` within ``cls`` subclass (as a class attribute).

        :Note:

            This method may throw exceptions in case the requested pattern was
            not registered. For exception specification, see documentation of
            `ezmlex.patterns.pattern()`.
        """
        from ezmlex.patterns import pattern
        return pattern(cls.patterns(), *args)