from pygments.lexer import RegexLexer
from pygments.token import *

__all__ = ['ILOCLexer']

class ILOCLexer(RegexLexer):
    name = 'Boppi'
    aliases = ['iloc']
    filenames = ['*.iloc']

    tokens = {
        'root': [
            (r'//.*?$', Comment),
            (r'(nop|add|sub|mult|div|addI|subI|rsubI|multI|divI|rdivI|lshift|lshiftI|rshift|rshiftI|or|orI|and|andI|xor|xorI|loadI|load|loadAI|loadAO|cload|cloadAI|cloadAO|store|storeAI|storeAO|cstore|cstoreAI|cstoreAO|i2i|c2c|c2i|i2c|cmp_LT|cmp_LE|cmp_EQ|cmp_GE|cmp_GT|cmp_NE|cbr|jumpI|jump|tbl|push|pop|cpush|cpop|in|out|cin|cout|halt|haltI)\b', Keyword),
            (r'\[|\]|;|,|=>|->', Punctuation),
            (r'<-', Operator),
            (r'@[A-Za-z][A-Za-z0-9_]*', Name.Variable.Global),
            (r'#[A-Za-z][A-Za-z0-9_]*', Name.Label),
            (r'[A-Za-z][A-Za-z0-9_]*', Name.Variable),
            (r'-?[0-9]+', Number.Integer),
            (r'"([^"\n\r]|\\")*"', String),
            (r'.+?', Text)
        ]
    }
