pmacs3/mode/console.py

25 lines
933 B
Python

import color, mode
from lex import Grammar, PatternRule, RegionRule
from mode.python import StringGrammar, PythonGrammar
class ConsoleGrammar(Grammar):
rules = [
RegionRule(r'string', r'"', StringGrammar, r'"'),
RegionRule(r'string', r"'", StringGrammar, r"'"),
RegionRule(r'console_input', r'^(?:>>>|-->)', PythonGrammar, '\n$'),
PatternRule(r'console_mesg', r'^[A-Za-z].*$'),
PatternRule(r'console_reserved', r'True|False|None'),
PatternRule(r'console_bareword', r'[a-zA-Z_][a-zA-Z0-9_]*'),
]
class Console(mode.Fundamental):
modename = 'Console'
grammar = ConsoleGrammar()
colors = {
'console_mesg': ('red', 'default', 'bold'),
'console_input.start': ('red', 'default', 'bold'),
'console_reserved': ('magenta', 'default', 'bold'),
'console_bareword': ('default', 'default', 'bold'),
}
install = Console.install