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
|
2007-07-21 11:40:53 -04:00
|
|
|
|
|
|
|
class TagGrammar(Grammar):
|
|
|
|
rules = [
|
|
|
|
RegionRule(r'string', r'"', Grammar, r'"'),
|
|
|
|
RegionRule(r'string', r"'", Grammar, r"'"),
|
|
|
|
PatternRule(r'namespace', r'[a-zA-Z_]+:'),
|
|
|
|
PatternRule(r'attrname', r'[^ =>\n]+(?==)'),
|
|
|
|
PatternRule(r'name', r'[^\[\] =>\n]+'),
|
|
|
|
]
|
|
|
|
|
|
|
|
class XMLGrammar(Grammar):
|
|
|
|
rules = [
|
|
|
|
# TODO: how does cdata work again?
|
|
|
|
RegionRule(r'comment', r'<!--', Grammar, r'-->'),
|
|
|
|
RegionRule(r'tag', r'<', TagGrammar, r'/?>'),
|
|
|
|
]
|
|
|
|
|
2007-10-21 20:55:29 -04:00
|
|
|
class XML(mode.Fundamental):
|
2007-10-18 17:07:35 -04:00
|
|
|
modename = 'XML'
|
|
|
|
extensions = ['.xml', '.xml.in']
|
|
|
|
grammar = XMLGrammar
|
|
|
|
colors = {
|
2007-07-21 11:40:53 -04:00
|
|
|
'comment.start': ('red', 'default'),
|
|
|
|
'comment.null': ('red', 'default'),
|
|
|
|
'comment.end': ('red', 'default'),
|
|
|
|
'tag.start': ('default', 'default'),
|
|
|
|
'tag.namespace': ('magenta', 'default'),
|
|
|
|
'tag.name': ('blue', 'default'),
|
|
|
|
'tag.attrname': ('cyan', 'default'),
|
|
|
|
'tag.string.start': ('green', 'default'),
|
|
|
|
'tag.string.null': ('green', 'default'),
|
|
|
|
'tag.string.end': ('green', 'default'),
|
|
|
|
'tag.end': ('default', 'default'),
|
|
|
|
}
|
2007-10-19 02:41:33 -04:00
|
|
|
|
|
|
|
install = XML.install
|