How to use the pyleri.Sequence 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
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):
    START = Ref()
    ni_item = Choice(Keyword('ni'), START)
    START = Sequence('[', List(ni_item), ']')


class TestPyleri(unittest.TestCase):

    def setUp(self):
        gc.collect()
github SiriDB / siridb-server / grammar / grammar.py View on Github external
most_greedy=False), '=>', 1)

    select_aggregate = Sequence(
        aggregate_functions,
        Optional(prefix_expr),
        Optional(suffix_expr))

    select_aggregates = List(select_aggregate, ',', 1)

    merge_as = Sequence(
        k_merge,
        k_as,
        string,
        Optional(Sequence(k_using, aggregate_functions)))

    set_address = Sequence(k_set, k_address, string)
    set_tee_pipe_name = Sequence(k_set, k_tee_pipe_name, Choice(
        k_false,
        string,
        most_greedy=False))
    set_backup_mode = Sequence(k_set, k_backup_mode, _boolean)
    set_drop_threshold = Sequence(k_set, k_drop_threshold, r_float)
    set_expression = Sequence(k_set, k_expression, r_regex)
    set_ignore_threshold = Sequence(k_set, k_ignore_threshold, _boolean)
    set_list_limit = Sequence(k_set, k_list_limit, r_uinteger)
    set_log_level = Sequence(k_set, k_log_level, log_keywords)
    set_name = Sequence(k_set, k_name, string)
    set_password = Sequence(k_set, k_password, string)
    set_port = Sequence(k_set, k_port, r_uinteger)
    set_select_points_limit = Sequence(
        k_set, k_select_points_limit, r_uinteger)
    set_timezone = Sequence(k_set, k_timezone, string)
github SiriDB / siridb-server / grammar / grammar.py View on Github external
f_points = Repeat(k_points, 1, 1)  # DEPRECATED

    f_difference = Sequence(
        k_difference,
        '(',
        Optional(time_expr),
        ')')
    f_derivative = Sequence(
        k_derivative,
        '(',
        List(time_expr, ',', 0, 2),
        ')')
    f_mean = Sequence(
        k_mean,
        '(', Optional(time_expr), ')')
    f_median = Sequence(
        k_median,
        '(', Optional(time_expr), ')')
    f_median_low = Sequence(
        k_median_low,
        '(', Optional(time_expr), ')')
    f_median_high = Sequence(
        k_median_high,
        '(', Optional(time_expr), ')')
    f_sum = Sequence(
        k_sum,
        '(', Optional(time_expr), ')')
    f_min = Sequence(
        k_min,
        '(', Optional(time_expr), ')')
    f_max = Sequence(
        k_max,
github SiriDB / siridb-server / grammar / grammar.py View on Github external
f_max = Sequence(
        k_max,
        '(', Optional(time_expr), ')')
    f_count = Sequence(
        k_count,
        '(', Optional(time_expr), ')')
    f_variance = Sequence(
        k_variance,
        '(', Optional(time_expr), ')')
    f_pvariance = Sequence(
        k_pvariance,
        '(', Optional(time_expr), ')')
    f_stddev = Sequence(
        k_stddev,
        '(', Optional(time_expr), ')')
    f_first = Sequence(
        k_first,
        '(', Optional(time_expr), ')')
    f_last = Sequence(
        k_last,
        '(', Optional(time_expr), ')')

    f_filter = Sequence(
        k_filter,
        '(',
        Optional(str_operator),
        Choice(
            string,
            r_integer,
            r_float,
            r_regex,
            k_nan,
github SiriDB / siridb-server / grammar / grammar.py View on Github external
most_greedy=False))

    alter_group = Sequence(k_group, group_name, Choice(
        set_expression,
        set_name,
        most_greedy=False))

    alter_server = Sequence(k_server, uuid, Choice(
        set_log_level,
        set_backup_mode,
        set_tee_pipe_name,
        set_address,
        set_port,
        most_greedy=False))

    alter_servers = Sequence(k_servers, Optional(where_server), Choice(
        set_log_level,
        set_tee_pipe_name,
        most_greedy=False))

    alter_user = Sequence(k_user, string, Choice(
        set_password,
        set_name,
        most_greedy=False))

    count_groups = Sequence(
        k_groups, Optional(where_group))
    count_pools = Sequence(
        k_pools, Optional(where_pool))
    count_series = Sequence(
        k_series, Optional(series_match), Optional(where_series))
    count_servers = Sequence(
github SiriDB / siridb-server / grammar / grammar.py View on Github external
drop_series = Sequence(
        k_series,
        Optional(series_match),
        Optional(where_series),
        Optional(set_ignore_threshold))
    drop_shards = Sequence(
        k_shards,
        Optional(where_shard),
        Optional(set_ignore_threshold))
    drop_server = Sequence(k_server, uuid)
    drop_user = Sequence(k_user, string)

    grant_user = Sequence(
        k_user, string, Optional(set_password))

    list_groups = Sequence(
        k_groups, Optional(group_columns), Optional(where_group))
    list_pools = Sequence(
        k_pools, Optional(pool_columns), Optional(where_pool))
    list_series = Sequence(
        k_series,
        Optional(series_columns),
        Optional(series_match),
        Optional(where_series))
    list_servers = Sequence(
        k_servers, Optional(server_columns), Optional(where_server))
    list_shards = Sequence(
        k_shards, Optional(shard_columns), Optional(where_shard))
    list_users = Sequence(
        k_users, Optional(user_columns), Optional(where_user))

    revoke_user = Sequence(k_user, string)
github SiriDB / siridb-server / grammar / grammar.py View on Github external
set_log_level,
        set_tee_pipe_name,
        most_greedy=False))

    alter_user = Sequence(k_user, string, Choice(
        set_password,
        set_name,
        most_greedy=False))

    count_groups = Sequence(
        k_groups, Optional(where_group))
    count_pools = Sequence(
        k_pools, Optional(where_pool))
    count_series = Sequence(
        k_series, Optional(series_match), Optional(where_series))
    count_servers = Sequence(
        k_servers, Optional(where_server))
    count_servers_received = Sequence(
        k_servers,
        k_received_points,
        Optional(where_server))
    count_servers_selected = Sequence(
        k_servers,
        k_selected_points,
        Optional(where_server))
    count_shards = Sequence(
        k_shards, Optional(where_shard))
    count_shards_size = Sequence(
        k_shards, k_size, Optional(where_shard))
    count_users = Sequence(
        k_users, Optional(where_user))
    count_series_length = Sequence(
github alastairreid / mra_tools / bin / explanations.py View on Github external
Keyword('TLBI_INSTRUCTION'),
                   Keyword('IC_INSTRUCTION'),
                   Keyword('DC_INSTRUCTION'),
                   Keyword('CONSTANT'),
                   Keyword('BARRIER_SCOPE'))
    type_property = Sequence(Keyword('TYPE'), types)
    bits = Regex('\'[0-9]+\'')
    integer = Regex('[0-9]+')
    number = Choice(bits, integer)
    multiple = Sequence(name, Token('*'), number)
    division = Sequence(name, Token('/'), number)
    addition = Sequence(name, Token('+'), number)
    subtraction = Sequence(name, Token('-'), number)
    subtraction_from = Sequence(number, Token('-'), name)
    encoded_property = Sequence(Keyword('ENCODED'), Choice(name, multiple, division, addition, subtraction, subtraction_from))
    default_property = Sequence(Keyword('DEFAULT'), Choice(name, number))
    multiple_of_property = Sequence(Keyword('MULTIPLE_OF'), number)
    constant_value_property = Sequence(Keyword('CONSTANT_VALUE'), imm_name)
    expr_property = Sequence(Keyword('EXPR'), Choice(name, multiple, division, addition, subtraction, subtraction_from, Keyword('PRESENCE')))
    prop = Choice(type_property,
                  encoded_property,
                  default_property,
                  multiple_of_property,
                  expr_property,
                  constant_value_property)
    START = Repeat(prop, mi=1)

exp_grammar = ExplanationGrammar()

class Explanation:
    def __init__(self, type, props, values=None):
        self.type = type
github SiriDB / siridb-server / grammar / grammar.py View on Github external
k_series,
        most_greedy=False)
    pool_columns = List(pool_props, ',', 1)

    bool_operator = Tokens('== !=')
    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),