# -- general -----------------------------------------------

FAILURE = 'failure'
SUCCESS = 'success'

BOL = 'bol'
EOL = 'eol'
EOF = 'eof'
ANY = 'any'
LITERAL = 'literal'
NOT_LITERAL = 'not literal'
CHARSET = 'charset'
NOT_CHARSET = 'not charset'
ASSERT = 'assert'
BRANCH = 'branch'
REPEAT = 'repeat'
REPEAT_RANGE = 'repeat range'
SUBPATTERN = 'subpattern'

OP_CODES = [
    FAILURE, SUCCESS,

    BOL, EOL, EOF,
    ANY,
    LITERAL, NOT_LITERAL,
    CHARSET, NOT_CHARSET,
    ASSERT,
    BRANCH,
    REPEAT, REPEAT_RANGE,
    ]

# -- charset stuff -----------------------------------------

CHARSET_LITERAL = 'literal'
CHARSET_RANGE = 'range'
CHARSET_SMALL = 'small'
CHARSET_BIG = 'big'

CHARSET_CODES = [
    FAILURE,
    CHARSET_LITERAL,
    CHARSET_RANGE,
    CHARSET_SMALL,
    CHARSET_BIG,
    ]
    
# -- convert to dictionaries for lookups -------------------

def makedict(list):
    dict = {}
    index = 0
    for item in list:
        dict[item] = index
        index += 1
    return dict

OP_CODES = makedict(OP_CODES)
CHARSET_CODES = makedict(CHARSET_CODES)
