branch : pmacs2
This commit is contained in:
moculus 2009-02-15 17:30:37 +00:00
parent 460e7b3004
commit c71dadf3e6
2 changed files with 25 additions and 15 deletions

11
IDEAS
View File

@ -1,3 +1,14 @@
2009/02/15:
Remove $MODE.lib in favor of $MODE.libs[]
Also, try generalize things like documentation lookup, syntax highlighting, etc,
more than they are to reduce the size of modes (see python and perl for the most
obvious examples). Other modes will probably benefit from this.
Now that comment-region uses commentc, make it able to work with languages who
use /*...*/ type commenting, rather than just //...\n type commenting.
2009/02/05: 2009/02/05:
Create some more rules for lexing that will help things like XML be more Create some more rules for lexing that will help things like XML be more

View File

@ -21,22 +21,24 @@ class PodGrammar(Grammar):
] ]
def _make_string_rules(forbidden): def _make_string_rules(forbidden):
#rule1 = PatternRule(r'scalar', r"\$[^\[\]\(\){}<>A-Za-z0-9 \\%s](?![A-Za-z0-9_])" % forbidden)
#rule2 = PatternRule(r'data', r"[^%s\\\@\$%%\&]+" % forbidden)
rules = [ rules = [
PatternRule(r'octal', r'\\[0-7]{3}'), PatternRule(r'octal', r'\\[0-7]{3}'),
PatternRule(r'escaped', r'\\.'), PatternRule(r'escaped', r'\\.'),
PatternRule(r'deref', r"\$+[A-Za-z0-9_](?:[A-Za-z0-9_]|::)*(?:(?:->)?{\$?(?:[a-zA-Z_][a-zA-Z_0-9]*|'(?:\\.|[^'\\])*'|\"(\\.|[^\\\"])*\")}|(?:->)?\[\$?[0-9a-zA-Z_]+\])+"), PatternRule(r'deref', r"\$+[A-Za-z0-9_](?:[A-Za-z0-9_]|::)*(?:(?:->)?{\$?(?:[a-zA-Z_][a-zA-Z_0-9]*|'(?:\\.|[^'\\])*'|\"(\\.|[^\\\"])*\")}|(?:->)?\[\$?[0-9a-zA-Z_]+\])+"),
PatternRule(r'length', r"\$#[A-Za-z0-9_](?:[A-Za-z0-9_]|::)*"), PatternRule(r'length', r"\$#[A-Za-z0-9_](?:[A-Za-z0-9_]|::)*"),
#rule1,
PatternRule(r'scalar', r"\$\$*[A-Za-z0-9_](?:[A-Za-z0-9_]|::)*"), PatternRule(r'scalar', r"\$\$*[A-Za-z0-9_](?:[A-Za-z0-9_]|::)*"),
PatternRule(r'cast', r"[\$\@\%\&]{.*?}"), PatternRule(r'cast', r"[\$\@\%\&]{.*?}"),
PatternRule(r'array', r"@\$*[A-Za-z_](?:[A-Za-z0-9_]|::)*"), PatternRule(r'array', r"@\$*[A-Za-z_](?:[A-Za-z0-9_]|::)*"),
#rule2,
] ]
return rules return rules
class NoParen(Grammar): rules = [PatternRule(r'data', 'r[^\)]+')]
class NoBrace(Grammar): rules = [PatternRule(r'data', 'r[^\}]+')]
class NoBracket(Grammar): rules = [PatternRule(r'data', 'r[^\]]+')]
class NoAngle(Grammar): rules = [PatternRule(r'data', 'r[^>]+')]
class NoHash(Grammar): rules = [PatternRule(r'data', 'r[^#]+')]
class DataGrammar(Grammar): rules = [PatternRule(r'data', '.+')]
class StrictStringGrammar(Grammar): class StrictStringGrammar(Grammar):
rules = [ rules = [
PatternRule(r'escaped', r"\\'"), PatternRule(r'escaped', r"\\'"),
@ -80,17 +82,14 @@ class PerlGrammar(Grammar):
rules = [ rules = [
RegionRule(r'heredoc', r"<<(?P<heredoc>[a-zA-Z_][a-zA-Z0-9_]+)", None, ';\n', StringGrammar, r'^%(heredoc)s$'), RegionRule(r'heredoc', r"<<(?P<heredoc>[a-zA-Z_][a-zA-Z0-9_]+)", None, ';\n', StringGrammar, r'^%(heredoc)s$'),
RegionRule(r'heredoc', r'<< *"(?P<heredoc>[a-zA-Z0-9_]+)" *;', StringGrammar, r'^%(heredoc)s$'), RegionRule(r'heredoc', r'<< *"(?P<heredoc>[a-zA-Z0-9_]+)" *;', StringGrammar, r'^%(heredoc)s$'),
RegionRule(r'heredoc', r"<< *'(?P<heredoc>[a-zA-Z0-9_]+)' *;", Grammar, r'^%(heredoc)s$'), RegionRule(r'heredoc', r"<< *'(?P<heredoc>[a-zA-Z0-9_]+)' *;", DataGrammar, r'^%(heredoc)s$'),
RegionRule(r'evaldoc', r"<< *`(?P<heredoc>[a-zA-Z0-9_]+)` *;", StringGrammar, r'^%(heredoc)s$'), RegionRule(r'evaldoc', r"<< *`(?P<heredoc>[a-zA-Z0-9_]+)` *;", StringGrammar, r'^%(heredoc)s$'),
RegionRule(r'endblock', r"^__END__|__DATA__ *$", Grammar, r''), RegionRule(r'endblock', r"^__END__|__DATA__ *$", DataGrammar, r''),
RegionRule(r'pod', r'^=[a-zA-Z0-9_]+', PodGrammar, r'^=cut'), RegionRule(r'pod', r'^=[a-zA-Z0-9_]+', PodGrammar, r'^=cut'),
OverridePatternRule(r'comment', r'#@@:(?P<token>[.a-zA-Z0-9_]+):(?P<mode>[.a-zA-Z0-9_]+) *$'), OverridePatternRule(r'comment', r'#@@:(?P<token>[.a-zA-Z0-9_]+):(?P<mode>[.a-zA-Z0-9_]+) *$'),
#PatternRule(r'prototype', r'\([\\@$%&*;]+\)'),
PatternGroupRule(r'prototype', r'delimiter', r'\(', r'prototype', r'[\[\]\\@$%&*;]+', r'delimiter', '\)'), PatternGroupRule(r'prototype', r'delimiter', r'\(', r'prototype', r'[\[\]\\@$%&*;]+', r'delimiter', '\)'),
PatternRule(r'comment', r'#.*$'), PatternRule(r'comment', r'#.*$'),
RegionRule(r'perl_string', r'"', StringGrammar, r'"'), RegionRule(r'perl_string', r'"', StringGrammar, r'"'),
RegionRule(r'perl_string', r"'", StrictStringGrammar, r"'"), RegionRule(r'perl_string', r"'", StrictStringGrammar, r"'"),
@ -157,11 +156,11 @@ class PerlGrammar(Grammar):
RegionRule(r'quoted', r'q[rqx](?P<delim>#)', StringGrammar, r'#'), RegionRule(r'quoted', r'q[rqx](?P<delim>#)', StringGrammar, r'#'),
# quote operator: q() and qw() do not interpolate # quote operator: q() and qw() do not interpolate
RegionRule(r'quoted', r'qw? *\(', Grammar, r'\)'), RegionRule(r'quoted', r'qw? *\(', NoParen, r'\)'),
RegionRule(r'quoted', r'qw? *{', Grammar, r'}'), RegionRule(r'quoted', r'qw? *{', NoBrace, r'}'),
RegionRule(r'quoted', r'qw? *<', Grammar, r'>'), RegionRule(r'quoted', r'qw? *<', NoAngle, r'>'),
RegionRule(r'quoted', r'qw? *\[', Grammar, r'\]'), RegionRule(r'quoted', r'qw? *\[', NoBracket, r'\]'),
RegionRule(r'quoted', r'qw?#', Grammar, r'#'), RegionRule(r'quoted', r'qw?#', NoHash, r'#'),
RegionRule(r'quoted', r'qw? *(?P<delim>[^ a-zA-Z0-9#])', Grammar, r'%(delim)s'), RegionRule(r'quoted', r'qw? *(?P<delim>[^ a-zA-Z0-9#])', Grammar, r'%(delim)s'),
PatternRule(r'perl_function', r"(?:[a-zA-Z_][a-zA-Z_0-9]*::)*[a-zA-Z_][a-zA-Z_0-9]*(?= *\()"), PatternRule(r'perl_function', r"(?:[a-zA-Z_][a-zA-Z_0-9]*::)*[a-zA-Z_][a-zA-Z_0-9]*(?= *\()"),