branch : pmacs2
This commit is contained in:
moculus 2008-09-09 22:43:22 +00:00
parent 83a5661e68
commit 6865b2a4e9
1 changed files with 36 additions and 57 deletions

View File

@ -1,67 +1,46 @@
import commands
import color, mode
from lex import Grammar, PatternRule, RegionRule, Grammar
from method import Method
from mode.perl import PerlGrammar
from mode.xml import TagGrammar
from mode.perl import StringGrammar, StrictStringGrammar
from lex import Grammar, PatternRule, RegionRule
class StringGrammar(Grammar):
rules = [
PatternRule(r'escaped', r'\\.'),
]
class BDSGrammar(Grammar):
rules = [
RegionRule(r'comment', r'<!--', Grammar, r'-->'),
RegionRule(r'xml_tag', r'< */?', TagGrammar, r'/?>'),
PatternRule(r'delimiter', r'[\[\]\{\}\(\),\?:]'),
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}'),
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})?"'),
RegionRule(r'string', '"', StringGrammar, '"'),
RegionRule(r'string', "'", StrictStringGrammar, "'"),
PatternRule(r'bds_operator', r'(?:&gt;=|&lt;=|&gt;|&lt;|==|&amp;&amp;|\|\||eq|ne)'),
PatternRule(r'comment', r'#.*$'),
PatternRule(r'bds_section', r'section(?= *\()'),
PatternRule(r'bds_component', r"[A-Z]{2}\d{3}-\d{3}-\d{3}(?= *\()"),
PatternRule(r'bds_attr_name', r"[a-z_]+(?==)"),
RegionRule(r'bds_attr_value', r'(?<=)"', StringGrammar, r'"'),
RegionRule(r'bds_attr_value', r"(?<=)'", StringGrammar, r"'"),
PatternRule(r'bds_num', r"-?(?:[0-9][0-9\.]*[0-9]|[0-9])"),
PatternRule(r'bds_alias', r"[a-z0-9]+(?=:[A-Z]{2}\d{3}-\d{3}-\d{3})"),
PatternRule(r'bds_id', r"[A-Z]{2}\d{3}-\d{3}-\d{3}"),
PatternRule(r'bds_func', r"[a-zA-Z0-9_]+(?= *\()"),
RegionRule(r'bds_string', r'"', StringGrammar, r'"'),
RegionRule(r'bds_string', r"'", StringGrammar, r"'"),
]
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
class BDS(mode.Fundamental):
modename = 'BDS'
basenames = ['components.xml']
grammar = BDSGrammar
opentokens = ('delimiter',)
opentags = {'(': ')', '[': ']', '{': '}'}
closetokens = ('delimiter',)
closetags = {')': '(', ']': '[', '}': '{'}
colors = {
'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'),
modename = 'bds'
extensions = ['.bds']
grammar = BDSGrammar
colors = {
'bds_section': ('blue', 'default', 'bold'),
'bds_component': ('magenta', 'default', 'bold'),
'bds_attr_name': ('blue', 'default', 'bold'),
'bds_attr_value.start': ('green', 'default', 'bold'),
'bds_attr_value.null': ('green', 'default', 'bold'),
'bds_attr_value.end': ('green', 'default', 'bold'),
'bds_num': ('red', 'default', 'bold'),
'bds_alias': ('magenta', 'default', 'bold'),
'bds_id': ('yellow', 'default', 'bold'),
'bds_func': ('cyan', 'default', 'bold'),
'bds_op': ('magenta', 'default', 'bold'),
'bds_string.start': ('red', 'default', 'bold'),
'bds_string.null': ('red', 'default', 'bold'),
'bds_string.end': ('red', 'default', 'bold'),
}
actions = [BDSMakeInstall, BDSCompileResources, BDSRestart]
def __init__(self, w):
mode.Fundamental.__init__(self, w)
self.add_bindings('close-paren', (')',))
self.add_bindings('close-brace', ('}',))
self.add_bindings('close-bracket', (']',))
install = BDS.install