pmacs3/mode/xml.py

37 lines
1.2 KiB
Python
Raw Normal View History

2007-07-21 11:40:53 -04:00
import color, mode2
from lex3 import Grammar, PatternRule, RegionRule
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'/?>'),
]
class XML(mode2.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'),
}