2007-07-23 15:28:27 -04:00
|
|
|
import commands
|
2007-07-21 11:40:53 -04:00
|
|
|
import color, mode2
|
|
|
|
from lex3 import Grammar, PatternRule, RegionRule, Grammar
|
2007-07-23 15:28:27 -04:00
|
|
|
from method import Method
|
2007-07-21 11:40:53 -04:00
|
|
|
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):
|
2007-10-18 17:07:35 -04:00
|
|
|
modename = 'BDS'
|
|
|
|
basenames = ['components.xml']
|
|
|
|
grammar = BDSGrammar
|
2007-07-21 11:40:53 -04:00
|
|
|
opentokens = ('delimiter',)
|
2007-10-18 17:07:35 -04:00
|
|
|
opentags = {'(': ')', '[': ']', '{': '}'}
|
2007-07-21 11:40:53 -04:00
|
|
|
closetokens = ('delimiter',)
|
2007-10-18 17:07:35 -04:00
|
|
|
closetags = {')': '(', ']': '[', '}': '{'}
|
|
|
|
colors = {
|
2007-07-23 15:28:27 -04:00
|
|
|
# comments
|
2007-07-21 11:40:53 -04:00
|
|
|
'comment.start': ('red', 'default'),
|
|
|
|
'comment.null': ('red', 'default'),
|
|
|
|
'comment.end': ('red', 'default'),
|
2007-07-23 15:28:27 -04:00
|
|
|
# xml tag
|
2007-07-21 11:40:53 -04:00
|
|
|
'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'),
|
2007-07-23 15:28:27 -04:00
|
|
|
# strings
|
2007-07-21 11:40:53 -04:00
|
|
|
'string.start': ('green', 'default'),
|
|
|
|
'string.octal': ('magenta', 'default'),
|
|
|
|
'string.escaped': ('magenta', 'default'),
|
|
|
|
'string.null': ('green', 'default'),
|
|
|
|
'string.end': ('green', 'default'),
|
2007-07-23 15:28:27 -04:00
|
|
|
# keywords, etc
|
2007-07-21 11:40:53 -04:00
|
|
|
'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', (']',))
|
2007-07-23 15:28:27 -04:00
|
|
|
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
|
2007-10-19 02:41:33 -04:00
|
|
|
|
|
|
|
install = BDS.install
|