85 lines
3.4 KiB
Python
85 lines
3.4 KiB
Python
import commands
|
|
import color, mode2
|
|
from lex3 import Grammar, PatternRule, RegionRule, Grammar
|
|
from method import Method
|
|
from mode.perl import PerlGrammar
|
|
from mode.xml import TagGrammar
|
|
from mode.perl import StringGrammar
|
|
|
|
class BDSGrammar(Grammar):
|
|
rules = [
|
|
RegionRule(r'comment', r'<!--', Grammar, r'-->'),
|
|
RegionRule(r'tag', r'< */?', TagGrammar, r'/?>'),
|
|
PatternRule(r'delimiter', r'[\[\]\{\}\(\),\?:]'),
|
|
PatternRule(r'derived', r'(?:FM|CD|FS|FM|TA)[0-9]{3}-[0-9]{3}-[0-9]{3}'),
|
|
PatternRule(r'question', r'GQ[0-9]{3}-[0-9]{3}-[0-9]{3}:MQ[0-9]{3}-[0-9]{3}-[0-9]{3}'),
|
|
PatternRule(r'bdsfunc', r'[A-Z_][A-Z0-9_]+(?= *\()'),
|
|
PatternRule(r'perlfunc', r'[a-zA-Z_][a-zA-Z0-9_]+(?= *\()'),
|
|
PatternRule(r'misquoted', r"'[A-Z]{2}[0-9]{3}-[0-9]{3}-[0-9]{3}(?::[A-Z]{2}[0-9]{3}-[0-9]{3}-[0-9]{3})?'"),
|
|
PatternRule(r'misquoted', r'"[A-Z]{2}[0-9]{3}-[0-9]{3}-[0-9]{3}(?::[A-Z]{2}[0-9]{3}-[0-9]{3}-[0-9]{3})?"'),
|
|
RegionRule(r'string', '"', StringGrammar, '"'),
|
|
RegionRule(r'string', "'", Grammar, "'"),
|
|
PatternRule(r'operator', r'(?:>=|<=|>|<|==|&&|\|\||eq|ne)'),
|
|
]
|
|
|
|
class BDS(mode2.Fundamental):
|
|
modename = 'BDS'
|
|
basenames = ['components.xml']
|
|
grammar = BDSGrammar
|
|
opentokens = ('delimiter',)
|
|
opentags = {'(': ')', '[': ']', '{': '}'}
|
|
closetokens = ('delimiter',)
|
|
closetags = {')': '(', ']': '[', '}': '{'}
|
|
colors = {
|
|
# comments
|
|
'comment.start': ('red', 'default'),
|
|
'comment.null': ('red', 'default'),
|
|
'comment.end': ('red', 'default'),
|
|
# xml tag
|
|
'tag.start': ('default', 'default'),
|
|
'tag.namespace': ('magenta', 'default'),
|
|
'tag.name': ('blue', 'default'),
|
|
'tag.attrname': ('blue', 'default'),
|
|
'tag.string.start': ('cyan', 'default'),
|
|
'tag.string.null': ('cyan', 'default'),
|
|
'tag.string.end': ('cyan', 'default'),
|
|
'tag.end': ('default', 'default'),
|
|
# strings
|
|
'string.start': ('green', 'default'),
|
|
'string.octal': ('magenta', 'default'),
|
|
'string.escaped': ('magenta', 'default'),
|
|
'string.null': ('green', 'default'),
|
|
'string.end': ('green', 'default'),
|
|
# keywords, etc
|
|
'derived': ('yellow', 'default'),
|
|
'question': ('yellow', 'default'),
|
|
'misquoted': ('yellow', 'red'),
|
|
'bdsfunc': ('magenta', 'default'),
|
|
'perlfunc': ('magenta', 'default'),
|
|
'operator': ('magenta', 'default'),
|
|
}
|
|
def __init__(self, w):
|
|
mode2.Fundamental.__init__(self, w)
|
|
self.add_bindings('close-paren', (')',))
|
|
self.add_bindings('close-brace', ('}',))
|
|
self.add_bindings('close-bracket', (']',))
|
|
self.add_action(BDSMakeInstall())
|
|
self.add_action(BDSCompileResources())
|
|
self.add_action(BDSRestart())
|
|
|
|
class BDSMakeInstall(Method):
|
|
def _execute(self, w, **vargs):
|
|
cmd = "perl Makefile.PL && make && make install"
|
|
(status, output) = commands.getstatusoutput(cmd)
|
|
if status == 0:
|
|
w.set_error("make succeeded")
|
|
else:
|
|
w.application.data_buffer("*bds-make-install*", output, switch_to=True)
|
|
w.set_error("make failed with %d" % status)
|
|
class BDSCompileResources(Method):
|
|
def _execute(self, w, **vargs):
|
|
pass
|
|
class BDSRestart(Method):
|
|
def _execute(self, w, **vargs):
|
|
pass
|