diff --git a/mode/iperl.py b/mode/iperl.py index ba82d4c..834bf51 100644 --- a/mode/iperl.py +++ b/mode/iperl.py @@ -1,37 +1,20 @@ import color, mode -#from lex import Grammar, PatternRule, RegionRule -#from mode.python import StringGrammar, PythonGrammar +from lex import Grammar, PatternRule, RegionRule +from mode.perl import StringGrammar, PerlGrammar -#class ReprGrammar(Grammar): -# rules = [ -# RegionRule(r'string', r'"', StringGrammar, r'"'), -# RegionRule(r'string', r"'", StringGrammar, r"'"), -# ] -#class ConsoleGrammar(Grammar): -# rules = [ -# PatternRule(r'console_mesg', r'^[A-Za-z].*$'), -# PatternRule(r'console_input', r'^>>>.*$'), -# PatternRule(r'console_input', r'^-->.*$'), -# RegionRule(r'string', r'"', StringGrammar, r'"'), -# RegionRule(r'string', r"'", StringGrammar, r"'"), -# #RegionRule(r'console_repr', r"<", ReprGrammar, r">"), -# PatternRule(r'console_reserved', r'True|False|None'), -# PatternRule(r'console_bareword', r'[a-zA-Z_][a-zA-Z0-9_]*'), -# ] -class Console(mode.Fundamental): +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(mode.Fundamental): modename = 'IPerl' -# grammar = ConsoleGrammar() -# colors = { -# 'console_mesg': ('magenta', 'default', 'bold'), -# 'console_input': ('cyan', 'default', 'bold'), -# 'console_reserved': ('magenta', 'default', 'bold'), -# 'console_bareword': ('default', 'default', 'bold'), -# 'console_repr.start': ('default', 'default', 'bold'), -# 'console_repr.null': ('blue', 'default', 'bold'), -# 'console_repr.string.start': ('cyan', 'default', 'bold'), -# 'console_repr.string.null': ('cyan', 'default', 'bold'), -# 'console_repr.string.end': ('cyan', 'default', 'bold'), -# 'console_repr.end': ('default', 'default', 'bold'), -# } + grammar = IperlGrammar() + colors = { + 'iperl_input.start': ('red', 'default', 'bold'), + 'iperl_reserved': ('magenta', 'default', 'bold'), + } -install = Console.install +install = Iperl.install