How to use the pyleri.elements.c_export function in pyleri

To help you get started, we’ve selected a few pyleri examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github transceptor-technology / pyleri / pyleri / repeat.py View on Github external
    @c_export
    def _run_export_c(self, c_indent, indent, enums, gid):
        # If the repeat is used as a duplication we can use the duplication
        # which is supported by libcleri
        if hasattr(self._element, 'name') \
                and self._min == 1 \
                and self._max == 1:
            return 'cleri_dup({}, {})'.format(
                gid,
                self._element.name)
        return 'cleri_repeat({}, {}, {}, {})'.format(
            gid,
            self._element._export_c(c_indent, indent, enums),
            self._min,
            self._max or 'undefined')
github transceptor-technology / pyleri / pyleri / tokens.py View on Github external
    @c_export
    def _run_export_c(self, c_indent, indent, enums, gid):
        return 'cleri_tokens({}, "{}")'.format(
            gid,
            ' '.join(self._tokens))
github transceptor-technology / pyleri / pyleri / optional.py View on Github external
    @c_export
    def _run_export_c(self, c_indent, indent, enums, gid):
        return 'cleri_optional({}, {})'.format(
            gid,
            self._element._export_c(c_indent, indent, enums))
github transceptor-technology / pyleri / pyleri / list.py View on Github external
    @c_export
    def _run_export_c(self, c_indent, indent, enums, gid):
        return 'cleri_list({}, {}, {}, {}, {}, {})'.format(
            gid,
            self._element._export_c(c_indent, indent, enums),
            self._delimiter._export_c(c_indent, indent, enums),
            self._min,
            self._max or '0',
            '1' if self._opt else '0')
github transceptor-technology / pyleri / pyleri / regex.py View on Github external
    @c_export
    def _run_export_c(self, c_indent, indent, enums, gid):
        assert not(self._compiled.flags & re.IGNORECASE), \
            'libcleri has currently no support for the re.IGNORECASE flag'
        return 'cleri_regex({}, "{}")'.format(
            gid,
            self._compiled.pattern
                .replace('\\', '\\\\')
                .replace('\'', '\\\'')
                .replace('\\"', '"')
                .replace('"', '\\"'))
github transceptor-technology / pyleri / pyleri / keyword.py View on Github external
    @c_export
    def _run_export_c(self, c_indent, indent, enums, gid):
        return 'cleri_keyword({}, "{}", {})'.format(
            gid,
            self._keyword,
            'CLERI_CASE_INSENSITIVE'
            if self._ign_case else 'CLERI_CASE_SENSITIVE')
github transceptor-technology / pyleri / pyleri / token.py View on Github external
    @c_export
    def _run_export_c(self, js_indent, indent, enums, gid):
        return 'cleri_token({}, "{}")'.format(
            gid,
            self._token)
github transceptor-technology / pyleri / pyleri / choice.py View on Github external
    @c_export
    def _run_export_c(self, c_indent, indent, enums, gid):
        new_indent = indent + 1
        value = ',\n'.join(['{indent}{elem}'.format(
            indent=c_indent * new_indent,
            elem=elem._export_c(
                c_indent,
                new_indent,
                enums)) for elem in self._elements])
        return 'cleri_choice(\n{gid},\n{mg},\n{num},\n{val}\n{indent})'.format(
            gid='{indent}{gid}'.format(
                indent=c_indent * (indent + 1),
                gid=gid),
            mg='{indent}{mg}'.format(
                indent=c_indent * (indent + 1),
                mg=('CLERI_FIRST_MATCH', 'CLERI_MOST_GREEDY')[
                    self._get_node_result == self._most_greedy_result]),