2007-10-21 20:55:29 -04:00
|
|
|
import color, mode
|
2007-10-21 20:52:48 -04:00
|
|
|
from lex import Grammar, PatternRule, RegionRule
|
2008-05-11 23:37:57 -04:00
|
|
|
from mode.python import StringGrammar, PythonGrammar
|
2007-07-21 11:40:53 -04:00
|
|
|
|
2008-05-11 23:37:57 -04:00
|
|
|
class ReprGrammar(Grammar):
|
|
|
|
rules = [
|
|
|
|
RegionRule(r'string', r'"', StringGrammar, r'"'),
|
|
|
|
RegionRule(r'string', r"'", StringGrammar, r"'"),
|
|
|
|
]
|
2007-07-21 11:40:53 -04:00
|
|
|
class ConsoleGrammar(Grammar):
|
|
|
|
rules = [
|
2008-03-16 11:39:17 -04:00
|
|
|
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"'"),
|
2008-05-11 23:37:57 -04:00
|
|
|
#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_]*'),
|
2007-07-21 11:40:53 -04:00
|
|
|
]
|
2007-10-21 20:55:29 -04:00
|
|
|
class Console(mode.Fundamental):
|
2007-10-18 17:07:35 -04:00
|
|
|
modename = 'Console'
|
2007-07-21 11:40:53 -04:00
|
|
|
grammar = ConsoleGrammar()
|
|
|
|
colors = {
|
2008-05-11 23:37:57 -04:00
|
|
|
'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'),
|
2007-07-21 11:40:53 -04:00
|
|
|
}
|
2007-10-19 02:41:33 -04:00
|
|
|
|
|
|
|
install = Console.install
|