2007-07-14 10:21:22 -04:00
|
|
|
import color, mode2
|
2007-06-25 12:37:40 -04:00
|
|
|
from lex2 import Grammar, PatternRule, RegionRule
|
2007-06-18 15:09:00 -04:00
|
|
|
|
2007-06-25 16:35:21 -04:00
|
|
|
class OpenTagGrammar(Grammar):
|
2007-06-18 15:09:00 -04:00
|
|
|
rules = [
|
2007-07-10 19:01:44 -04:00
|
|
|
RegionRule(r'string', r'"', Grammar, r'"'),
|
|
|
|
RegionRule(r'string', r"'", Grammar, r"'"),
|
2007-07-08 19:16:53 -04:00
|
|
|
PatternRule(r'namespace', r'[a-zA-Z_]+:'),
|
|
|
|
PatternRule(r'attrname', r'[^ =>\n]+(?==)'),
|
|
|
|
PatternRule(r'name', r'[^ =>\n]+'),
|
2007-06-18 15:09:00 -04:00
|
|
|
]
|
|
|
|
|
|
|
|
class XMLGrammar(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]+ *>'),
|
2007-06-18 15:09:00 -04:00
|
|
|
]
|
2007-03-06 10:05:38 -05:00
|
|
|
|
2007-06-25 11:59:44 -04:00
|
|
|
class XML(mode2.Fundamental):
|
2007-07-10 19:01:44 -04:00
|
|
|
grammar = XMLGrammar
|
2007-03-06 10:05:38 -05:00
|
|
|
def __init__(self, w):
|
2007-06-25 11:59:44 -04:00
|
|
|
mode2.Fundamental.__init__(self, w)
|
2007-03-06 10:05:38 -05:00
|
|
|
self.colors = {
|
2007-06-29 09:37:58 -04:00
|
|
|
'comment.start': color.build('red', 'default'),
|
|
|
|
'comment.null': color.build('red', 'default'),
|
|
|
|
'comment.end': color.build('red', 'default'),
|
2007-06-18 15:09:00 -04:00
|
|
|
'opentag.start': color.build('default', 'default'),
|
|
|
|
'opentag.namespace': color.build('magenta', 'default'),
|
|
|
|
'opentag.name': color.build('blue', 'default'),
|
|
|
|
'opentag.attrname': color.build('cyan', 'default'),
|
|
|
|
'opentag.string.start': color.build('green', 'default'),
|
|
|
|
'opentag.string.null': color.build('green', 'default'),
|
|
|
|
'opentag.string.end': color.build('green', 'default'),
|
|
|
|
'opentag.end': color.build('default', 'default'),
|
2007-03-06 10:05:38 -05:00
|
|
|
}
|
|
|
|
def name(self):
|
|
|
|
return "XML"
|