refyre.reader package#

Submodules#

refyre.reader.ExpressionGenerator module#

class refyre.reader.ExpressionGenerator.ExpressionGenerator(string)[source]#

Bases: object

The ExpressionGenerator class takes in an input generator string, such as test$.txt, and returns a lambda function that can be used to evaluate the expressions at various points.

For example, test$.txt returns a lambda function, that when called at i = 1, returns test1.txt

This class is a static class; it’s sole purpose is to create an organized location to generate complex expressions.

For now, only numbers are supported. You can generate number expressions using the ‘$’ symbol as shown above.

convert_generator_expression()[source]#
generate_expression()[source]#
is_null_generator()[source]#

By “null” generator, I just mean a genexp that doesn’t have any special characters, i.e. one that will stay the same

is_valid_genexp()[source]#
reverse_generator_expression(string)[source]#

refyre.reader.Lexer module#

class refyre.reader.Lexer.Lexer(input_file)[source]#

Bases: object

refyre’s static lexer

Fundamental assumptions:
  • There are 4 spaces / tab. On some systems, there are 8, hence I’ve made a SPACES_PER_TAB variable that can be adjusted

  • Only one cluster can be specified per line. The lexer is designed to error if someone tries some dumb shit

SPACES_PER_TAB = 4#
extract_line_data()[source]#

Packages all the important line data into a Token() object

lex()[source]#

Performs “lexical analysis”, a.k.a grabs all the important information from each line

preprocess()[source]#

Goal: Clean up the new file in preparation for lexical analysis. This means we’re going to get rid of the unnecessary clutter.

refyre.reader.Parser module#

class refyre.reader.Parser.Parser(tokens)[source]#

Bases: object

Refyre’s static parser

parse(INF=-10)[source]#
refyre.reader.Parser.pop(stack)[source]#
refyre.reader.Parser.push(stack, item)[source]#

refyre.reader.PatternGenerator module#

class refyre.reader.PatternGenerator.PatternGenerator(pattern_string, given_type=None)[source]#

Bases: object

The pattern generator is designed to parse all pattern based strings and return regex versions of them that can be used to pattern match.

We created the generator to help differentiate between glob patterns and regex. Most of the time, people use glob, but sometimes the power of regex matching does come in handy.

A glob string will come in the normal form. A regex string will start with an r before the actual pattern.

ex: “a?.txt” is a glob pattern. “ra?.txt” is regex.

GLOB_STARTER = 'g!'#
REGEX_STARTER = 'r!'#
convert_generator_expression()[source]#
get_pattern_type()[source]#
is_valid_genexp()[source]#
is_valid_regex()[source]#

Module contents#