pmacs3/mode/bds.py

68 lines
2.9 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
2008-06-19 16:20:07 -04:00
from mode.perl import StringGrammar, StrictStringGrammar
2007-07-21 11:40:53 -04:00
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-06-19 16:20:07 -04:00
PatternRule(r'bds_alias', r'[a-z0-9]+(?=:)'),
PatternRule(r'keyword', r'if|else|elsif|unless'),
PatternRule(r'bds_derived', r'(?:CN|FM|CD|IS|FS|FM|TA)[0-9]{3}-[0-9]{3}-[0-9]{3}'),
2008-03-16 02:16:41 -04:00
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, '"'),
2008-06-19 16:20:07 -04:00
RegionRule(r'string', "'", StrictStringGrammar, "'"),
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
]
2008-04-18 23:32:08 -04:00
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-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-06-19 16:20:07 -04:00
'bds_alias': ('yellow', 'default', 'bold'),
'bds_derived': ('yellow', 'default', 'bold'),
'bds_question': ('yellow', 'default', 'bold'),
'bds_misquoted': ('yellow', 'red', 'bold'),
'bds_function': ('magenta', 'default', 'bold'),
'bds_perlfunc': ('magenta', 'default', 'bold'),
'bds_operator': ('magenta', 'default', 'bold'),
2007-07-21 11:40:53 -04:00
}
2008-04-18 23:32:08 -04:00
actions = [BDSMakeInstall, BDSCompileResources, BDSRestart]
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', (']',))
2007-10-19 02:41:33 -04:00
install = BDS.install