2007-07-14 10:21:22 -04:00
|
|
|
import color, mode2
|
2007-07-15 09:44:20 -04:00
|
|
|
from lex3 import Grammar, PatternRule, RegionRule
|
2007-06-18 15:09:00 -04:00
|
|
|
|
2007-07-18 07:22:12 -04:00
|
|
|
class TagGrammar(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]+(?==)'),
|
2007-07-18 07:22:12 -04:00
|
|
|
PatternRule(r'name', r'[^\[\] =>\n]+'),
|
2007-06-18 15:09:00 -04:00
|
|
|
]
|
|
|
|
|
|
|
|
class XMLGrammar(Grammar):
|
|
|
|
rules = [
|
2007-07-18 07:22:12 -04:00
|
|
|
# TODO: how does cdata work again?
|
2007-07-10 19:01:44 -04:00
|
|
|
RegionRule(r'comment', r'<!--', Grammar, r'-->'),
|
2007-07-18 07:22:12 -04:00
|
|
|
RegionRule(r'tag', r'<', TagGrammar, r'/?>'),
|
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-07-18 07:22:12 -04:00
|
|
|
colors = {
|
|
|
|
'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-03-06 10:05:38 -05:00
|
|
|
def name(self):
|
|
|
|
return "XML"
|