from mode import Fundamental
from lex import Grammar, PatternRule, RegionRule
from mode.perl import StringGrammar, PerlGrammar

class IperlGrammar(Grammar):
    rules = [
        RegionRule(r'string', r'"', StringGrammar, r'"'),
        RegionRule(r'string', r"'", StringGrammar, r"'"),
        RegionRule(r'iperl_input', r'^(?:>>>|\.\.>)', PerlGrammar, '\n$'),
        PatternRule(r'iperl_reserved', r'undef'),
    ]
class Iperl(Fundamental):
    name    = 'IPerl'
    grammar = IperlGrammar()
    colors  = {
        'iperl_input.start': ('red', 'default', 'bold'),
        'iperl_reserved':    ('magenta', 'default', 'bold'),
    }
    _bindings = {
        'iperl-start': ('M-e',),
    }

install = Iperl.install