more mode and efficiency improvements

--HG--
branch : pmacs2
This commit is contained in:
moculus 2008-09-30 21:11:50 +00:00
parent a0f0de1bc3
commit 0aaa84c894
3 changed files with 15 additions and 4 deletions

View File

@ -55,6 +55,7 @@ class Application(object):
self.token_colors = { self.token_colors = {
'comment': ('red', 'default', 'bold'), 'comment': ('red', 'default', 'bold'),
'comment.start': ('red', 'default', 'bold'), 'comment.start': ('red', 'default', 'bold'),
'comment.data': ('red', 'default', 'bold'),
'comment.null': ('red', 'default', 'bold'), 'comment.null': ('red', 'default', 'bold'),
'comment.end': ('red', 'default', 'bold'), 'comment.end': ('red', 'default', 'bold'),
'continuation': ('red', 'default', 'bold'), 'continuation': ('red', 'default', 'bold'),

View File

@ -468,6 +468,7 @@ class Python(mode.Fundamental):
'classname': ('green', 'default', 'bold'), 'classname': ('green', 'default', 'bold'),
'rawstring.start': ('green', 'default', 'bold'), 'rawstring.start': ('green', 'default', 'bold'),
'rawstring.data': ('green', 'default', 'bold'), 'rawstring.data': ('green', 'default', 'bold'),
'rawstring.null': ('green', 'default', 'bold'),
'rawstring.escaped': ('magenta', 'default', 'bold'), 'rawstring.escaped': ('magenta', 'default', 'bold'),
'rawstring.end': ('green', 'default', 'bold'), 'rawstring.end': ('green', 'default', 'bold'),
'system_identifier': ('cyan', 'default', 'bold'), 'system_identifier': ('cyan', 'default', 'bold'),

View File

@ -2,9 +2,15 @@ import color, method, mode
from lex import Grammar, PatternRule, RegionRule from lex import Grammar, PatternRule, RegionRule
class StringGrammar1(Grammar): class StringGrammar1(Grammar):
rules = [PatternRule(r'data', r'[^"]+')] rules = [
PatternRule(r'data', r'[^"&]+'),
PatternRule(r'escaped', r'&[a-z]+;'),
]
class StringGrammar2(Grammar): class StringGrammar2(Grammar):
rules = [PatternRule(r'data', r"[^']+")] rules = [
PatternRule(r'data', r"[^'&]+"),
PatternRule(r'escaped', r'&[a-z]+;'),
]
class CommentGrammar(Grammar): class CommentGrammar(Grammar):
rules = [PatternRule(r'data', r'(?:[^-]|-(?!-)|--(?!>))+')] rules = [PatternRule(r'data', r'(?:[^-]|-(?!-)|--(?!>))+')]
@ -29,10 +35,10 @@ class XMLGrammar(Grammar):
PatternRule(r'data', r'[^<& \n]+'), PatternRule(r'data', r'[^<& \n]+'),
PatternRule(r'spaces', r' +'), PatternRule(r'spaces', r' +'),
RegionRule(r'comment', r'<!--', CommentGrammar, r'-->'), RegionRule(r'comment', r'<!--', CommentGrammar, r'-->'),
RegionRule(r'xml_tag', r'<', TagGrammar, r'/?>'), RegionRule(r'xml_tag', r'<(?!\?)', TagGrammar, r'/?>'),
PatternRule(r'xml_entity', r'&[a-z]+;'), PatternRule(r'xml_entity', r'&[a-z]+;'),
PatternRule(r'eol', r'\n'), PatternRule(r'eol', r'\n'),
RegionRule(r'metadata', r'<\?', MetadataGrammar, r'\?>'), RegionRule(r'xml_metadata', r'<\?', MetadataGrammar, r'\?>'),
] ]
class XmlValidate(method.shell.Exec): class XmlValidate(method.shell.Exec):
@ -57,6 +63,9 @@ class XML(mode.Fundamental):
extensions = ['.xml', '.xml.in', '.xsl', '.xsd'] extensions = ['.xml', '.xml.in', '.xsl', '.xsd']
grammar = XMLGrammar grammar = XMLGrammar
colors = { colors = {
'xml_metadata.start': ('magenta', 'default', 'bold'),
'xml_metadata.data': ('magenta', 'default', 'bold'),
'xml_metadata.end': ('magenta', 'default', 'bold'),
'xml_tag.start': ('default', 'default', 'bold'), 'xml_tag.start': ('default', 'default', 'bold'),
'xml_tag.namespace': ('magenta', 'default', 'bold'), 'xml_tag.namespace': ('magenta', 'default', 'bold'),
'xml_tag.name': ('blue', 'default', 'bold'), 'xml_tag.name': ('blue', 'default', 'bold'),