How to use the pyleri.Token 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 alastairreid / mra_tools / bin / explanations.py View on Github external
Keyword('CONDITION'),
                   Keyword('INVERTED_CONDITION'),
                   Keyword('SYSREG'),
                   Keyword('PREFETCH_OP'),
                   Keyword('AT_INSTRUCTION'),
                   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)
github SiriDB / siridb-server / grammar / grammar.py View on Github external
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)
    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,
github alastairreid / mra_tools / bin / explanations.py View on Github external
Keyword('PREFETCH_OP'),
                   Keyword('AT_INSTRUCTION'),
                   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:
github SiriDB / siridb-server / grammar / grammar.py View on Github external
Tokens(', |'),
        Keyword('union'),
        most_greedy=False)
    k_uptime = Keyword('uptime')
    k_user = Keyword('user')
    k_users = Keyword('users')
    k_using = Keyword('using')
    k_uuid = Keyword('uuid')
    k_variance = Keyword('variance')
    k_version = Keyword('version')
    k_warning = Keyword('warning')
    k_where = Keyword('where')
    k_who_am_i = Keyword('who_am_i')
    k_write = Keyword('write')
    c_difference = Choice(
        Token('-'),
        k_difference,
        most_greedy=False)

    access_keywords = Choice(
        k_read,
        k_write,
        k_modify,
        k_full,
        k_select,
        k_show,
        k_list,
        k_count,
        k_create,
        k_insert,
        k_drop,
        k_grant,
github SiriDB / siridb-server / grammar / grammar.py View on Github external
k_for = Keyword('for')
    k_from = Keyword('from')
    k_full = Keyword('full')
    k_grant = Keyword('grant')
    k_group = Keyword('group')
    k_groups = Keyword('groups')
    k_help = Choice(Keyword('help'), Token('?'))
    k_idle_percentage = Keyword('idle_percentage')
    k_idle_time = Keyword('idle_time')
    k_inf = Keyword('inf')
    k_info = Keyword('info')
    k_ignore_threshold = Keyword('ignore_threshold')
    k_insert = Keyword('insert')
    k_integer = Keyword('integer')
    k_intersection = Choice(
        Token('&'),
        Keyword('intersection'),
        most_greedy=False)
    k_ip_support = Keyword('ip_support')
    k_last = Keyword('last')
    k_length = Keyword('length')
    k_libuv = Keyword('libuv')
    k_limit = Keyword('limit')
    k_list = Keyword('list')
    k_list_limit = Keyword('list_limit')
    k_log = Keyword('log')
    k_log_level = Keyword('log_level')
    k_max = Keyword('max')
    k_max_open_files = Keyword('max_open_files')
    k_mean = Keyword('mean')
    k_median = Keyword('median')
    k_median_low = Keyword('median_low')
github alastairreid / mra_tools / bin / explanations.py View on Github external
Keyword('INVERTED_CONDITION'),
                   Keyword('SYSREG'),
                   Keyword('PREFETCH_OP'),
                   Keyword('AT_INSTRUCTION'),
                   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()
github SiriDB / siridb-server / grammar / grammar.py View on Github external
k_server = Keyword('server')
    k_servers = Keyword('servers')
    k_set = Keyword('set')
    k_sid = Keyword('sid')
    k_shards = Keyword('shards')
    k_show = Keyword('show')
    k_size = Keyword('size')
    k_start = Keyword('start')
    k_startup_time = Keyword('startup_time')
    k_status = Keyword('status')
    k_stddev = Keyword('stddev')
    k_string = Keyword('string')
    k_suffix = Keyword('suffix')
    k_sum = Keyword('sum')
    k_symmetric_difference = Choice(
        Token('^'),
        Keyword('symmetric_difference'),
        most_greedy=False)
    k_sync_progress = Keyword('sync_progress')
    k_tee_pipe_name = Keyword('tee_pipe_name')
    k_timeit = Keyword('timeit')
    k_timezone = Keyword('timezone')
    k_time_precision = Keyword('time_precision')
    k_to = Keyword('to')
    k_true = Keyword('true')
    k_type = Keyword('type')
    k_union = Choice(
        Tokens(', |'),
        Keyword('union'),
        most_greedy=False)
    k_uptime = Keyword('uptime')
    k_user = Keyword('user')
github alastairreid / mra_tools / bin / asm.py View on Github external
def process_element(instr_name, enc_name, explanations, types, el):
    if type(el.element) is Token and str(el.element) in '{}()':
        return ([], [])
    elif el.element.name == 'text':
        els = ['"{}"'.format(el.string)]
        return (els, [], [])
    elif el.element.name == 'doublespace':
        return (['spc()'], [], [])
    elif el.element.name == 'space':
        return (['def_spc()'], [], [])
    elif el.element.name == 'link':
        link = el.string + '_' + enc_name
        exp = explanations[link]
        if (exp.type == 'asm_immediate' or exp.type == 'asm_signed_immediate'):
            n_bits = get_bitconcat_n_bits(types, exp.props['encoded_in'])
            return (['hex_bits_{}({})'.format(n_bits, exp.props['encoded_in'])], [exp.props['encoded_in']], [link])
        # TODO FIXME SIGNED
        # elif exp.type == 'asm_signed_immediate':
github SiriDB / siridb-server / grammar / grammar.py View on Github external
k_duration_num = Keyword('duration_num')
    k_end = Keyword('end')
    k_error = Keyword('error')
    k_expression = Keyword('expression')
    k_false = Keyword('false')
    k_fifo_files = Keyword('fifo_files')
    k_filter = Keyword('filter')
    k_first = Keyword('first')
    k_float = Keyword('float')
    k_for = Keyword('for')
    k_from = Keyword('from')
    k_full = Keyword('full')
    k_grant = Keyword('grant')
    k_group = Keyword('group')
    k_groups = Keyword('groups')
    k_help = Choice(Keyword('help'), Token('?'))
    k_idle_percentage = Keyword('idle_percentage')
    k_idle_time = Keyword('idle_time')
    k_inf = Keyword('inf')
    k_info = Keyword('info')
    k_ignore_threshold = Keyword('ignore_threshold')
    k_insert = Keyword('insert')
    k_integer = Keyword('integer')
    k_intersection = Choice(
        Token('&'),
        Keyword('intersection'),
        most_greedy=False)
    k_ip_support = Keyword('ip_support')
    k_last = Keyword('last')
    k_length = Keyword('length')
    k_libuv = Keyword('libuv')
    k_limit = Keyword('limit')
github alastairreid / mra_tools / bin / explanations.py View on Github external
Keyword('BITMASK_IMMEDIATE_64'),
                   Keyword('CONDITION'),
                   Keyword('INVERTED_CONDITION'),
                   Keyword('SYSREG'),
                   Keyword('PREFETCH_OP'),
                   Keyword('AT_INSTRUCTION'),
                   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)