pmacs3/mode_console.py

33 lines
1.2 KiB
Python

import color, mode2
from lex2 import Grammar, PatternRule, RegionRule
from mode_python import StringGrammar
class ConsoleGrammar(Grammar):
rules = [
PatternRule(r'mesg', r'^[A-Za-z].*$'),
PatternRule(r'input', r'^>>>.*$'),
PatternRule(r'input', r'^-->.*$'),
#PatternRule(r'output', r'^ .*$'),
RegionRule(r'string', r'"', StringGrammar, r'"'),
RegionRule(r'string', r"'", StringGrammar, r"'"),
PatternRule(r'bareword', r'[a-zA-Z_][a-zA-Z0-9_]*'),
]
class Console(mode2.Fundamental):
grammar = ConsoleGrammar()
def __init__(self, w):
mode2.Fundamental.__init__(self, w)
self.colors = {
'mesg': color.build('blue', 'default'),
'input': color.build('cyan', 'default'),
'output': color.build('default', 'default'),
'string.start': color.build('green', 'default'),
'string.octal': color.build('magenta', 'default'),
'string.escaped': color.build('magenta', 'default'),
'string.null': color.build('green', 'default'),
'string.end': color.build('green', 'default'),
}
def name(self):
return "Console"