parent
16c4448bac
commit
22b963c6cc
29
mode_tt.py
29
mode_tt.py
|
@ -1,19 +1,20 @@
|
||||||
import color, mode2
|
import color, mode2
|
||||||
from lex3 import Grammar, PatternRule, RegionRule
|
from lex3 import Grammar, PatternRule, RegionRule
|
||||||
|
from mode_xml import OpenTagGrammar
|
||||||
|
from mode_perl import StringGrammar
|
||||||
|
|
||||||
class TagGrammar(Grammar):
|
class DirectiveGrammar(Grammar):
|
||||||
rules = [
|
rules = [
|
||||||
RegionRule(r'string', r'(?P<tag>["\'])', Grammar, r'%(tag)s'),
|
PatternRule(r'keyword', r'BLOCK|CALL|CASE|CATCH|CLEAR|DEBUG|DEFAULT|FINAL|FILTER|FOREACH|ELSIF|ELSE|END|GET|IF|INCLUDE|INSERT|LAST|MACRO|META|NEXT|PERL|PROCESS|RAWPERL|RETURN|SET|STOP|SWITCH|TAGS|THROW|TRY|UNLESS|USE|WHILE|WRAPPER'),
|
||||||
PatternRule(r'namespace', pattern=r'[a-zA-Z_]+:'),
|
RegionRule(r'string', r'"', StringGrammar, r'"'),
|
||||||
PatternRule(r'attrname', pattern=r'[^ =>\n]+(?==)'),
|
RegionRule(r'string', r"'", StringGrammar, r"'"),
|
||||||
PatternRule(r'name', pattern=r'[^ =>\n]+'),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
class TemplateGrammar(Grammar):
|
class TemplateGrammar(Grammar):
|
||||||
rules = [
|
rules = [
|
||||||
RegionRule(r'comment', r'<!--', Grammar, r'-->'),
|
RegionRule(r'comment', r'<!--', Grammar, r'-->'),
|
||||||
RegionRule(r'template', r'\[\%', Grammar, r'%%\]'),
|
RegionRule(r'directive', r'\[\%', DirectiveGrammar, r'%%\]'),
|
||||||
RegionRule(r'opentag', r'<', TagGrammar, r'/?>'),
|
RegionRule(r'opentag', r'<', OpenTagGrammar, r'/?>'),
|
||||||
PatternRule(r'closetag', pattern=r'< */ *[ =>\n]+ *>'),
|
PatternRule(r'closetag', pattern=r'< */ *[ =>\n]+ *>'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -26,9 +27,17 @@ class Template(mode2.Fundamental):
|
||||||
self.add_bindings('close-bracket', (']',))
|
self.add_bindings('close-bracket', (']',))
|
||||||
self.colors = {
|
self.colors = {
|
||||||
'comment': color.build('red', 'default'),
|
'comment': color.build('red', 'default'),
|
||||||
'template.start': color.build('magenta', 'default'),
|
|
||||||
'template.null': color.build('magenta', 'default'),
|
'directive.start': color.build('magenta', 'default'),
|
||||||
'template.end': color.build('magenta', 'default'),
|
'directive.keyword': color.build('cyan', 'default'),
|
||||||
|
'directive.string.start': color.build('green', 'default'),
|
||||||
|
'directive.string.escaped': color.build('magenta', 'default'),
|
||||||
|
'directive.string.octal': color.build('magenta', 'default'),
|
||||||
|
'directive.string.null': color.build('green', 'default'),
|
||||||
|
'directive.string.end': color.build('green', 'default'),
|
||||||
|
'directive.null': color.build('magenta', 'default'),
|
||||||
|
'directive.end': color.build('magenta', 'default'),
|
||||||
|
|
||||||
'opentag.start': color.build('default', 'default'),
|
'opentag.start': color.build('default', 'default'),
|
||||||
'opentag.namespace': color.build('magenta', 'default'),
|
'opentag.namespace': color.build('magenta', 'default'),
|
||||||
'opentag.name': color.build('blue', 'default'),
|
'opentag.name': color.build('blue', 'default'),
|
||||||
|
|
Loading…
Reference in New Issue