branch : pmacs2
This commit is contained in:
moculus 2008-04-18 14:12:30 +00:00
parent 6d0116c45f
commit 4c0f08a913
3 changed files with 23 additions and 17 deletions

View File

@ -1,12 +1,22 @@
import color, mode
from lex import Grammar, PatternRule, RegionRule
from mode.perl import StringGrammar
#from mode.perl import StringGrammar
class StringGrammar(Grammar):
rules = [
PatternRule(r'cheetah_placeholder', r'\${[a-zA-Z0-9_.\[\]]+}'),
PatternRule(r'cheetah_placeholder', r'\$[a-zA-Z0-9_.\[\]]+'),
PatternRule(r'octal', r'\\[0-7]{3}'),
PatternRule(r'escaped', r'\\.'),
]
class TagGrammar(Grammar):
rules = [
PatternRule(r'placeholder', r'\$[a-zA-Z0-9_]+'),
RegionRule(r'string', r'"', Grammar, r'"'),
RegionRule(r'string', r"'", Grammar, r"'"),
PatternRule(r'cheetah_placeholder', r'\${[a-zA-Z0-9_.\[\]]+}'),
PatternRule(r'cheetah_placeholder', r'\$[a-zA-Z0-9_.\[\]]+'),
RegionRule(r'string', r'"', StringGrammar, r'"'),
RegionRule(r'string', r"'", StringGrammar, r"'"),
PatternRule(r'namespace', r'[a-zA-Z_]+:'),
PatternRule(r'attrname', r'[^ =>\n]+(?==)'),
PatternRule(r'name', r'[^\[\] =>\n]+'),
@ -16,7 +26,8 @@ class TemplateGrammar(Grammar):
rules = [
RegionRule(r'comment', r'#\*', Grammar, r'\*#'),
PatternRule(r'comment', r'##.*\n'),
PatternRule(r'cheetah_placeholder', r'\$[a-zA-Z0-9_]+'),
PatternRule(r'cheetah_placeholder', r'\${[a-zA-Z0-9_.\[\]]+}'),
PatternRule(r'cheetah_placeholder', r'\$[a-zA-Z0-9_.\[\]]+'),
PatternRule(r'cheetah_directive', r'#.*?[#\n]'),
RegionRule(r'cheetah_tag', r'</?', TagGrammar, r'/?>'),
]

View File

@ -8,12 +8,6 @@ class StringGrammar(Grammar):
PatternRule(r'octal', r'\\[0-7]{3}'),
PatternRule(r'escaped', r'\\.'),
]
class RawStringGrammar(Grammar):
rules = [
PatternRule(r'escaped', r'\\\\'),
PatternRule(r'escaped', r"\\'"),
PatternRule(r'escaped', r'\\"'),
]
class PythonGrammar(Grammar):
rules = [
@ -28,10 +22,10 @@ class PythonGrammar(Grammar):
PatternRule(r'private_identifier', r'__[a-zA-Z0-9_]*'),
PatternRule(r'hidden_identifier', r'_[a-zA-Z0-9_]*'),
RegionRule(r'rawstring', r'r"""', RawStringGrammar, r'"""'),
RegionRule(r'rawstring', r"r'''", RawStringGrammar, r"'''"),
RegionRule(r'rawstring', r'r"', RawStringGrammar, r'"'),
RegionRule(r'rawstring', r"r'", RawStringGrammar, r"'"),
RegionRule(r'rawstring', r'r"""', StringGrammar, r'"""'),
RegionRule(r'rawstring', r"r'''", StringGrammar, r"'''"),
RegionRule(r'rawstring', r'r"', StringGrammar, r'"'),
RegionRule(r'rawstring', r"r'", StringGrammar, r"'"),
RegionRule(r'string', r'u?"""', StringGrammar, r'"""'),
RegionRule(r'string', r"u?'''", StringGrammar, r"'''"),
RegionRule(r'string', r'u?"', StringGrammar, r'"'),

View File

@ -14,7 +14,8 @@ class RSTGrammar(Grammar):
PatternGroupRule(r'title', r'title', r'^.*?\n', r'title_under', r'^=+\n'),
PatternGroupRule(r'subtitle', r'subtitle_over', r'^-+\n', r'subtitle',
r'^.*?\n', r'subtitle_under', r'^-+\n'),
PatternGroupRule(r'subtitle', r'subtitle', r'^.*?\n', r'subtitle_under', r'^-+\n'),
PatternGroupRule(r'subtitle', r'subtitle', r'^.*?\n', r'subtitle_under',
r'^-+\n'),
# this is kind of a hack, ugh
PatternGroupRule(r'definition', r'term', r'^[^ ]+\n', r'definition', r'^ +'),
@ -71,7 +72,7 @@ class RST(mode.Fundamental):
'reference': ('blue', 'default'),
'footnote': ('blue', 'default'),
'citation': ('blue', 'default'),
'rst_url': ('blue', 'default'),
'rst_url': ('blue', 'default'),
'bullet': ('magenta', 'default'),
'enumeration': ('magenta', 'default'),