pmacs3/mode/bds.py

67 lines
2.7 KiB
Python
Raw Normal View History

import commands
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, Grammar
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'-->'),
2008-03-16 02:16:41 -04:00
RegionRule(r'xml_tag', r'< */?', TagGrammar, r'/?>'),
2007-07-21 11:40:53 -04:00
PatternRule(r'delimiter', r'[\[\]\{\}\(\),\?:]'),
2008-03-16 02:16:41 -04:00
PatternRule(r'bds_derived', r'(?:FM|CD|FS|FM|TA)[0-9]{3}-[0-9]{3}-[0-9]{3}'),
PatternRule(r'bds_question', r'GQ[0-9]{3}-[0-9]{3}-[0-9]{3}:MQ[0-9]{3}-[0-9]{3}-[0-9]{3}'),
PatternRule(r'bds_function', r'[A-Z_][A-Z0-9_]+(?= *\()'),
PatternRule(r'bds_perlfunc', r'[a-zA-Z_][a-zA-Z0-9_]+(?= *\()'),
PatternRule(r'bds_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'bds_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})?"'),
2007-07-21 11:40:53 -04:00
RegionRule(r'string', '"', StringGrammar, '"'),
RegionRule(r'string', "'", Grammar, "'"),
2008-03-16 02:16:41 -04:00
PatternRule(r'bds_operator', r'(?:&gt;=|&lt;=|&gt;|&lt;|==|&amp;&amp;|\|\||eq|ne)'),
2007-07-21 11:40:53 -04:00
]
2007-10-21 20:55:29 -04:00
class BDS(mode.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 = {
2008-03-16 02:16:41 -04:00
'bds_derived': ('yellow', 'default'),
'bds_question': ('yellow', 'default'),
'bds_misquoted': ('yellow', 'red'),
'bds_function': ('magenta', 'default'),
'bds_perlfunc': ('magenta', 'default'),
'bds_operator': ('magenta', 'default'),
2007-07-21 11:40:53 -04:00
}
def __init__(self, w):
2007-10-21 20:55:29 -04:00
mode.Fundamental.__init__(self, w)
2007-07-21 11:40:53 -04:00
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
2007-10-19 02:41:33 -04:00
install = BDS.install