2007-07-14 10:21:22 -04:00
|
|
|
import color, mode2
|
2007-07-10 19:01:44 -04:00
|
|
|
from lex2 import Grammar, PatternRule, RegionRule, Grammar
|
|
|
|
from mode_perl import PerlGrammar
|
|
|
|
from mode_xml import OpenTagGrammar
|
|
|
|
from mode_perl import StringGrammar
|
2007-06-26 15:35:17 -04:00
|
|
|
|
|
|
|
class BDSGrammar(Grammar):
|
|
|
|
rules = [
|
2007-07-10 19:01:44 -04:00
|
|
|
RegionRule(r'comment', r'<!--', Grammar, r'-->'),
|
|
|
|
RegionRule(r'opentag', r'<', OpenTagGrammar, r'/?>'),
|
2007-07-08 19:16:53 -04:00
|
|
|
PatternRule(r'closetag', r'< */ *[ =>\n]+ *>'),
|
|
|
|
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})?"'),
|
2007-07-10 19:01:44 -04:00
|
|
|
RegionRule(r'string', '"', StringGrammar, '"'),
|
|
|
|
RegionRule(r'string', "'", Grammar, "'"),
|
2007-07-08 19:16:53 -04:00
|
|
|
PatternRule(r'operator', r'(?:>=|<=|>|<|==|&&|\|\||eq|ne)'),
|
2007-06-26 15:35:17 -04:00
|
|
|
]
|
|
|
|
|
|
|
|
class BDS(mode2.Fundamental):
|
2007-07-10 19:01:44 -04:00
|
|
|
grammar = BDSGrammar
|
2007-07-12 19:06:33 -04:00
|
|
|
opentokens = ('delimiter',)
|
2007-06-26 15:35:17 -04:00
|
|
|
opentags = {'(': ')', '[': ']', '{': '}'}
|
2007-07-12 19:06:33 -04:00
|
|
|
closetokens = ('delimiter',)
|
2007-06-26 15:35:17 -04:00
|
|
|
closetags = {')': '(', ']': '[', '}': '{'}
|
|
|
|
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.colors = {
|
|
|
|
'comment.start': color.build('red', 'default'),
|
|
|
|
'comment.null': color.build('red', 'default'),
|
|
|
|
'comment.end': color.build('red', 'default'),
|
|
|
|
'opentag.start': color.build('default', 'default'),
|
|
|
|
'opentag.namespace': color.build('magenta', 'default'),
|
|
|
|
'opentag.name': color.build('blue', 'default'),
|
|
|
|
'opentag.attrname': color.build('blue', 'default'),
|
|
|
|
'opentag.string.start': color.build('cyan', 'default'),
|
|
|
|
'opentag.string.null': color.build('cyan', 'default'),
|
|
|
|
'opentag.string.end': color.build('cyan', 'default'),
|
|
|
|
'opentag.end': color.build('default', 'default'),
|
|
|
|
'string.start': color.build('green', 'default'),
|
|
|
|
'string.octal': color.build('magenta', 'default'),
|
|
|
|
'string.escaped': color.build('magenta', 'default'),
|
|
|
|
'string.null': color.build('green', 'default'),
|
|
|
|
'string.end': color.build('green', 'default'),
|
|
|
|
'derived': color.build('yellow', 'default'),
|
|
|
|
'question': color.build('yellow', 'default'),
|
|
|
|
'misquoted': color.build('yellow', 'red'),
|
|
|
|
'bdsfunc': color.build('magenta', 'default'),
|
|
|
|
'perlfunc': color.build('magenta', 'default'),
|
|
|
|
'operator': color.build('magenta', 'default'),
|
|
|
|
}
|
|
|
|
def name(self):
|
|
|
|
return "BDS"
|