How to use the pyleri.Prio 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 / test / test_pyleri.py View on Github external
NameAssignedError,
    MissingStartError,
    UnusedElementError)  # nopep8
from examples import JsonGrammar  # nopep8


class _TestGrammar1(Grammar):
    k_test = Keyword('test')
    k_ignore_case = Keyword('ignore_case', ign_case=True)
    START = Sequence(k_test, k_ignore_case)


class _TestGrammar2(Grammar):
    k_ni = Keyword('ni')
    s_seq = Sequence('(', THIS, ')')
    START = Prio(
        k_ni,
        s_seq,
        Sequence(THIS, Keyword('and'), THIS),
        Sequence(THIS, Keyword('or'), THIS))


class _TestGrammar3(Grammar):
    s_tic_tac = Sequence(Keyword('tic'), Keyword('tac'))
    s_tic_tac_toe = Sequence(Keyword('tic'), Keyword('tac'), Keyword('toe'))

    START = Sequence(
        Choice(s_tic_tac, s_tic_tac_toe),
        Choice(s_tic_tac, s_tic_tac_toe, most_greedy=False))


class _TestGrammar4(Grammar):
github SiriDB / siridb-server / grammar / grammar.py View on Github external
int_expr),
        Sequence(Choice(k_server, k_status), str_operator, string),
        Sequence(
            Choice(k_start, k_end, most_greedy=False),
            int_operator,
            time_expr),
        Sequence(
            k_type,
            bool_operator,
            Choice(k_number, k_log, most_greedy=False)),
        Sequence('(', THIS, ')'),
        Sequence(THIS, k_and, THIS),
        Sequence(THIS, k_or, THIS)))

    # where user
    where_user = Sequence(k_where, Prio(
        Sequence(k_name, str_operator, string),
        Sequence(k_access, int_operator, access_keywords),
        Sequence('(', THIS, ')'),
        Sequence(THIS, k_and, THIS),
        Sequence(THIS, k_or, THIS)))

    series_setopr = Choice(
        k_union,
        c_difference,
        k_intersection,
        k_symmetric_difference,
        most_greedy=False)

    series_parentheses = Sequence('(', THIS, ')')

    series_all = Choice(Token('*'), k_all, most_greedy=False)
github SiriDB / siridb-server / grammar / grammar.py View on Github external
int_operator = Tokens('< > == != <= >=')
    str_operator = Tokens('< > == != <= >= ~ !~')

    # where group
    where_group = Sequence(k_where, Prio(
        Sequence(k_series, int_operator, int_expr),
        Sequence(
            Choice(k_expression, k_name, most_greedy=False),
            str_operator,
            string),
        Sequence('(', THIS, ')'),
        Sequence(THIS, k_and, THIS),
        Sequence(THIS, k_or, THIS)))

    # where pool
    where_pool = Sequence(k_where, Prio(
        Sequence(pool_props, int_operator, int_expr),
        Sequence('(', THIS, ')'),
        Sequence(THIS, k_and, THIS),
        Sequence(THIS, k_or, THIS)))

    # where series
    where_series = Sequence(k_where, Prio(
        Sequence(
            Choice(k_length, k_pool, most_greedy=False),
            int_operator,
            int_expr),
        Sequence(k_name, str_operator, string),
        Sequence(
            Choice(k_start, k_end, most_greedy=False),
            int_operator,
            time_expr),
github SiriDB / siridb-server / grammar / grammar.py View on Github external
log_keywords = Choice(
        k_debug,
        k_info,
        k_warning,
        k_error,
        k_critical,
        most_greedy=False)

    int_expr = Prio(
        r_integer,
        Sequence('(', THIS, ')'),
        Sequence(THIS, Tokens('+ - * % /'), THIS))

    string = Choice(r_singleq_str, r_doubleq_str, most_greedy=False)

    time_expr = Prio(
        r_time_str,
        k_now,
        string,
        r_integer,
        Sequence('(', THIS, ')'),
        Sequence(THIS, Tokens('+ - * % /'), THIS))

    series_columns = List(Choice(
        k_name,
        k_type,
        k_length,
        k_start,
        k_end,
        k_pool,
        most_greedy=False), ',', 1)
github SiriDB / siridb-server / grammar / grammar.py View on Github external
int_expr),
        Sequence(k_name, str_operator, string),
        Sequence(
            Choice(k_start, k_end, most_greedy=False),
            int_operator,
            time_expr),
        Sequence(
            k_type,
            bool_operator,
            Choice(k_string, k_integer, k_float, most_greedy=False)),
        Sequence('(', THIS, ')'),
        Sequence(THIS, k_and, THIS),
        Sequence(THIS, k_or, THIS)))

    # where server
    where_server = Sequence(k_where, Prio(
        Sequence(Choice(
            k_active_handles,
            k_active_tasks,
            k_buffer_size,
            k_fifo_files,
            k_idle_percentage,
            k_idle_time,
            k_port,
            k_pool,
            k_startup_time,
            k_max_open_files,
            k_mem_usage,
            k_open_files,
            k_received_points,
            k_selected_points,
            k_uptime,
github SiriDB / siridb-server / grammar / grammar.py View on Github external
k_grant,
        k_revoke,
        k_alter,
        most_greedy=False)

    _boolean = Choice(k_true, k_false, most_greedy=False)

    log_keywords = Choice(
        k_debug,
        k_info,
        k_warning,
        k_error,
        k_critical,
        most_greedy=False)

    int_expr = Prio(
        r_integer,
        Sequence('(', THIS, ')'),
        Sequence(THIS, Tokens('+ - * % /'), THIS))

    string = Choice(r_singleq_str, r_doubleq_str, most_greedy=False)

    time_expr = Prio(
        r_time_str,
        k_now,
        string,
        r_integer,
        Sequence('(', THIS, ')'),
        Sequence(THIS, Tokens('+ - * % /'), THIS))

    series_columns = List(Choice(
        k_name,
github SiriDB / siridb-server / grammar / grammar.py View on Github external
series_setopr = Choice(
        k_union,
        c_difference,
        k_intersection,
        k_symmetric_difference,
        most_greedy=False)

    series_parentheses = Sequence('(', THIS, ')')

    series_all = Choice(Token('*'), k_all, most_greedy=False)
    series_name = Repeat(string, 1, 1)
    group_name = Repeat(r_grave_str, 1, 1)
    series_re = Repeat(r_regex, 1, 1)
    uuid = Choice(r_uuid_str, string, most_greedy=False)
    group_match = Repeat(r_grave_str, 1, 1)
    series_match = Prio(
        List(Choice(
            series_all,
            series_name,
            group_match,
            series_re,
            most_greedy=False), series_setopr, 1),
        Choice(
            series_all,
            series_name,
            group_match,
            series_re,
            most_greedy=False),
        series_parentheses,
        Sequence(THIS, series_setopr, THIS),
    )