parent
3a36d4f149
commit
691f454dbe
23
mode_bds.py
23
mode_bds.py
|
@ -1,17 +1,13 @@
|
||||||
import color, lex2, mode2
|
import color, lex2, mode2
|
||||||
from lex2 import Grammar, PatternRule, RegionRule
|
from lex2 import Grammar, PatternRule, RegionRule, Grammar
|
||||||
|
from mode_perl import PerlGrammar
|
||||||
class StringGrammar(Grammar):
|
from mode_xml import OpenTagGrammar
|
||||||
rules = [
|
from mode_perl import StringGrammar
|
||||||
PatternRule(r'octal', r'\\[0-7]{3}'),
|
|
||||||
PatternRule(r'escaped', r'\\.'),
|
|
||||||
]
|
|
||||||
lex2.add('xml-string', StringGrammar)
|
|
||||||
|
|
||||||
class BDSGrammar(Grammar):
|
class BDSGrammar(Grammar):
|
||||||
rules = [
|
rules = [
|
||||||
RegionRule(r'comment', r'<!--', lex2.get('null'), r'-->'),
|
RegionRule(r'comment', r'<!--', Grammar, r'-->'),
|
||||||
RegionRule(r'opentag', r'<', lex2.get('xml-opentag'), r'/?>'),
|
RegionRule(r'opentag', r'<', OpenTagGrammar, r'/?>'),
|
||||||
PatternRule(r'closetag', r'< */ *[ =>\n]+ *>'),
|
PatternRule(r'closetag', r'< */ *[ =>\n]+ *>'),
|
||||||
PatternRule(r'delimiter', r'[\[\]\{\}\(\),\?:]'),
|
PatternRule(r'delimiter', r'[\[\]\{\}\(\),\?:]'),
|
||||||
PatternRule(r'derived', r'(?:FM|CD|FS|FM|TA)[0-9]{3}-[0-9]{3}-[0-9]{3}'),
|
PatternRule(r'derived', r'(?:FM|CD|FS|FM|TA)[0-9]{3}-[0-9]{3}-[0-9]{3}'),
|
||||||
|
@ -20,14 +16,13 @@ class BDSGrammar(Grammar):
|
||||||
PatternRule(r'perlfunc', r'[a-zA-Z_][a-zA-Z0-9_]+(?= *\()'),
|
PatternRule(r'perlfunc', r'[a-zA-Z_][a-zA-Z0-9_]+(?= *\()'),
|
||||||
PatternRule(r'misquoted', r"'[A-Z]{2}[0-9]{3}-[0-9]{3}-[0-9]{3}(?::[A-Z]{2}[0-9]{3}-[0-9]{3}-[0-9]{3})?'"),
|
PatternRule(r'misquoted', r"'[A-Z]{2}[0-9]{3}-[0-9]{3}-[0-9]{3}(?::[A-Z]{2}[0-9]{3}-[0-9]{3}-[0-9]{3})?'"),
|
||||||
PatternRule(r'misquoted', r'"[A-Z]{2}[0-9]{3}-[0-9]{3}-[0-9]{3}(?::[A-Z]{2}[0-9]{3}-[0-9]{3}-[0-9]{3})?"'),
|
PatternRule(r'misquoted', r'"[A-Z]{2}[0-9]{3}-[0-9]{3}-[0-9]{3}(?::[A-Z]{2}[0-9]{3}-[0-9]{3}-[0-9]{3})?"'),
|
||||||
RegionRule(r'string', '"', lex2.get('perl-string'), '"'),
|
RegionRule(r'string', '"', StringGrammar, '"'),
|
||||||
RegionRule(r'string', "'", lex2.get('null'), "'"),
|
RegionRule(r'string', "'", Grammar, "'"),
|
||||||
PatternRule(r'operator', r'(?:>=|<=|>|<|==|&&|\|\||eq|ne)'),
|
PatternRule(r'operator', r'(?:>=|<=|>|<|==|&&|\|\||eq|ne)'),
|
||||||
]
|
]
|
||||||
lex2.add('bds', BDSGrammar)
|
|
||||||
|
|
||||||
class BDS(mode2.Fundamental):
|
class BDS(mode2.Fundamental):
|
||||||
grammar = lex2.get('bds')
|
grammar = BDSGrammar
|
||||||
opentoken = 'delimiter'
|
opentoken = 'delimiter'
|
||||||
opentags = {'(': ')', '[': ']', '{': '}'}
|
opentags = {'(': ')', '[': ']', '{': '}'}
|
||||||
closetoken = 'delimiter'
|
closetoken = 'delimiter'
|
||||||
|
|
49
mode_perl.py
49
mode_perl.py
|
@ -12,7 +12,6 @@ class PodGrammar(Grammar):
|
||||||
PatternRule(r'entry', r'(?:(?<=^=begin)|(?<=^=end)) +.*$'),
|
PatternRule(r'entry', r'(?:(?<=^=begin)|(?<=^=end)) +.*$'),
|
||||||
PatternRule(r'entry', r'(?<=^=encoding) +.*$'),
|
PatternRule(r'entry', r'(?<=^=encoding) +.*$'),
|
||||||
]
|
]
|
||||||
lex2.add('perl-pod', PodGrammar)
|
|
||||||
|
|
||||||
class StringGrammar(Grammar):
|
class StringGrammar(Grammar):
|
||||||
rules = [
|
rules = [
|
||||||
|
@ -25,22 +24,21 @@ class StringGrammar(Grammar):
|
||||||
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_]|::)*"),
|
||||||
]
|
]
|
||||||
lex2.add('perl-string', StringGrammar)
|
|
||||||
|
|
||||||
class PerlGrammar(Grammar):
|
class PerlGrammar(Grammar):
|
||||||
rules = [
|
rules = [
|
||||||
RegionRule(r'heredoc1', r"<<(?P<heredoc>[a-zA-Z0-9_]+) *;", lex2.get('perl-string'), r'^%(heredoc)s$'),
|
RegionRule(r'heredoc1', r"<<(?P<heredoc>[a-zA-Z0-9_]+) *;", StringGrammar, r'^%(heredoc)s$'),
|
||||||
RegionRule(r'heredoc1', r'<< *"(?P<heredoc>[a-zA-Z0-9_]+)" *;', lex2.get('perl-string'), r'^%(heredoc)s$'),
|
RegionRule(r'heredoc1', r'<< *"(?P<heredoc>[a-zA-Z0-9_]+)" *;', StringGrammar, r'^%(heredoc)s$'),
|
||||||
RegionRule(r'heredoc2', r"<< *'(?P<heredoc>[a-zA-Z0-9_]+)' *;", lex2.get('null'), r'^%(heredoc)s$'),
|
RegionRule(r'heredoc2', r"<< *'(?P<heredoc>[a-zA-Z0-9_]+)' *;", Grammar, r'^%(heredoc)s$'),
|
||||||
RegionRule(r'eval_heredoc', r"<< *`(?P<heredoc>[a-zA-Z0-9_]+)` *;", lex2.get('perl-string'), r'^%(heredoc)s$'),
|
RegionRule(r'eval_heredoc', r"<< *`(?P<heredoc>[a-zA-Z0-9_]+)` *;", StringGrammar, r'^%(heredoc)s$'),
|
||||||
|
|
||||||
RegionRule(r'endblock', r"^__END__|__DATA__ *$", lex2.get('null'), r''),
|
RegionRule(r'endblock', r"^__END__|__DATA__ *$", Grammar, r''),
|
||||||
RegionRule(r'pod', r'^=[a-zA-Z0-9_]+', lex2.get('perl-pod'), r'^=cut'),
|
RegionRule(r'pod', r'^=[a-zA-Z0-9_]+', PodGrammar, r'^=cut'),
|
||||||
|
|
||||||
PatternRule(r'comment', r'#.*$'),
|
PatternRule(r'comment', r'#.*$'),
|
||||||
RegionRule(r'string1', r'"', lex2.get('perl-string'), r'"'),
|
RegionRule(r'string1', r'"', StringGrammar, r'"'),
|
||||||
RegionRule(r'string2', r"'", lex2.get('null'), r"'"),
|
RegionRule(r'string2', r"'", Grammar, r"'"),
|
||||||
RegionRule(r'evalstring', r"`", lex2.get('perl-string'), r"`"),
|
RegionRule(r'evalstring', r"`", StringGrammar, r"`"),
|
||||||
PatternRule(r'number', r'0?\.[0-9]+|[0-9]+(?:\.[0-9]+)?'),
|
PatternRule(r'number', r'0?\.[0-9]+|[0-9]+(?:\.[0-9]+)?'),
|
||||||
PatternRule(r'keyword', r"(?<!->)(?:STDIN|STDERR|STDOUT|continue|do|else|elsif|eval|foreach|for|if|last|my|next|our|package|require|return|sub|undef|unless|until|use|while)(?![a-zA-Z0-9_])"),
|
PatternRule(r'keyword', r"(?<!->)(?:STDIN|STDERR|STDOUT|continue|do|else|elsif|eval|foreach|for|if|last|my|next|our|package|require|return|sub|undef|unless|until|use|while)(?![a-zA-Z0-9_])"),
|
||||||
PatternRule(r'hash_key', r'(?<={)[A-Za-z0-9_]+(?=})'),
|
PatternRule(r'hash_key', r'(?<={)[A-Za-z0-9_]+(?=})'),
|
||||||
|
@ -56,17 +54,17 @@ class PerlGrammar(Grammar):
|
||||||
PatternRule(r'deref', r"[@%\$&\*](?={)"),
|
PatternRule(r'deref', r"[@%\$&\*](?={)"),
|
||||||
|
|
||||||
# match regexes
|
# match regexes
|
||||||
RegionRule(r'match', r'(?:(?<==~)|(?<=!~)|(?<=\()|(?<=split)) *(?P<delim>/)', lex2.get('perl-string'), r'/[a-z]*'),
|
RegionRule(r'match', r'(?:(?<==~)|(?<=!~)|(?<=\()|(?<=split)) *(?P<delim>/)', StringGrammar, r'/[a-z]*'),
|
||||||
RegionRule(r'match', r'm *(?P<delim>[^ #a-zA-Z0-9_])', lex2.get('perl-string'), r'%(delim)s[a-z]*'),
|
RegionRule(r'match', r'm *(?P<delim>[^ #a-zA-Z0-9_])', StringGrammar, r'%(delim)s[a-z]*'),
|
||||||
RegionRule(r'match', r'm(?P<delim>#)', lex2.get('perl-string'), r'#[a-z]*'),
|
RegionRule(r'match', r'm(?P<delim>#)', StringGrammar, r'#[a-z]*'),
|
||||||
|
|
||||||
# replace regexes
|
# replace regexes
|
||||||
DualRegionRule(r'replace', r's *(?P<delim>[^ a-zA-Z0-9_])', lex2.get('perl-string'), r'%(delim)s', lex2.get('perl-string'), r'%(delim)s[a-z]*'),
|
DualRegionRule(r'replace', r's *(?P<delim>[^ a-zA-Z0-9_])', StringGrammar, r'%(delim)s', StringGrammar, r'%(delim)s[a-z]*'),
|
||||||
DualRegionRule(r'replace', r's(?P<delim>#)', lex2.get('perl-string'), r'#', lex2.get('perl-string'), r'#[a-z]*'),
|
DualRegionRule(r'replace', r's(?P<delim>#)', StringGrammar, r'#', StringGrammar, r'#[a-z]*'),
|
||||||
|
|
||||||
# translate operator
|
# translate operator
|
||||||
DualRegionRule(r'translate', r'(?:y|tr) *(?P<delim>[^ a-zA-Z0-9_])', lex2.get('null'), r'%(delim)s', lex2.get('null'), r'%(delim)s[a-z]*'),
|
DualRegionRule(r'translate', r'(?:y|tr) *(?P<delim>[^ a-zA-Z0-9_])', Grammar, r'%(delim)s', Grammar, r'%(delim)s[a-z]*'),
|
||||||
DualRegionRule(r'translate', r'(?:y|tr)#', lex2.get('null'), r'#', lex2.get('null'), r'#[a-z]*'),
|
DualRegionRule(r'translate', r'(?:y|tr)#', Grammar, r'#', Grammar, r'#[a-z]*'),
|
||||||
|
|
||||||
# some more basic stuff
|
# some more basic stuff
|
||||||
PatternRule(r'package', r"(?<=package )(?:[a-zA-Z_][a-zA-Z_0-9]*::)*[a-zA-Z_][a-zA-Z_0-9]*"),
|
PatternRule(r'package', r"(?<=package )(?:[a-zA-Z_][a-zA-Z_0-9]*::)*[a-zA-Z_][a-zA-Z_0-9]*"),
|
||||||
|
@ -79,12 +77,12 @@ class PerlGrammar(Grammar):
|
||||||
PatternRule(r'builtin', r"(?<!->)&?(?:write|warn|wantarray|waitpid|wait|vec|values|utime|use|untie|unshift|unpack|unlink|undef|umask|ucfirst|uc|truncate|times|time|tied|tie|telldir|tell|syswrite|system|sysseek|sysread|sysopen|syscall|symlink|substr|sub|study|stat|srand|sqrt|sprintf|split|splice|sort|socketpair|socket|sleep|sin|shutdown|shmwrite|shmread|shmget|shmctl|shift|setsockopt|setservent|setpwent|setprotoent|setpriority|setpgrp|setnetent|sethostent|setgrent|send|semop|semget|semctl|select|seekdir|seek|scalar|rmdir|rindex|rewinddir|reverse|return|reset|require|rename|ref|redo|recv|readpipe|readlink|readline|readdir|read|rand|quotemeta|push|prototype|printf|print|pos|pop|pipe|package|pack|our|ord|opendir|open|oct|no|next|my|msgsnd|msgrcv|msgget|msgctl|mkdir|map|lstat|log|lock|localtime|local|listen|link|length|lcfirst|lc|last|kill|keys|join|ioctl|int|index|import|hex|grep|goto|gmtime|glob|getsockopt|getsockname|getservent|getservbyport|getservbyname|getpwuid|getpwnam|getpwent|getprotoent|getprotobynumber|getprotobyname|getpriority|getppid|getpgrp|getpeername|getnetent|getnetbyname|getnetbyaddr|getlogin|gethostent|gethostbyname|gethostbyaddr|getgrnam|getgrgid|getgrent|getc|formline|format|fork|flock|fileno|fcntl|exp|exit|exists|exec|eval|eof|endservent|endpwent|endprotoent|endnetent|endhostent|endgrent|each|dump|do|die|delete|defined|dbmopen|dbmclose|crypt|cos|continue|connect|closedir|close|chroot|chr|chown|chop|chomp|chmod|chdir|caller|bless|binmode|bind|atan2|alarm|accept|abs)(?![a-zA-Z0-9_])"),
|
PatternRule(r'builtin', r"(?<!->)&?(?:write|warn|wantarray|waitpid|wait|vec|values|utime|use|untie|unshift|unpack|unlink|undef|umask|ucfirst|uc|truncate|times|time|tied|tie|telldir|tell|syswrite|system|sysseek|sysread|sysopen|syscall|symlink|substr|sub|study|stat|srand|sqrt|sprintf|split|splice|sort|socketpair|socket|sleep|sin|shutdown|shmwrite|shmread|shmget|shmctl|shift|setsockopt|setservent|setpwent|setprotoent|setpriority|setpgrp|setnetent|sethostent|setgrent|send|semop|semget|semctl|select|seekdir|seek|scalar|rmdir|rindex|rewinddir|reverse|return|reset|require|rename|ref|redo|recv|readpipe|readlink|readline|readdir|read|rand|quotemeta|push|prototype|printf|print|pos|pop|pipe|package|pack|our|ord|opendir|open|oct|no|next|my|msgsnd|msgrcv|msgget|msgctl|mkdir|map|lstat|log|lock|localtime|local|listen|link|length|lcfirst|lc|last|kill|keys|join|ioctl|int|index|import|hex|grep|goto|gmtime|glob|getsockopt|getsockname|getservent|getservbyport|getservbyname|getpwuid|getpwnam|getpwent|getprotoent|getprotobynumber|getprotobyname|getpriority|getppid|getpgrp|getpeername|getnetent|getnetbyname|getnetbyaddr|getlogin|gethostent|gethostbyname|gethostbyaddr|getgrnam|getgrgid|getgrent|getc|formline|format|fork|flock|fileno|fcntl|exp|exit|exists|exec|eval|eof|endservent|endpwent|endprotoent|endnetent|endhostent|endgrent|each|dump|do|die|delete|defined|dbmopen|dbmclose|crypt|cos|continue|connect|closedir|close|chroot|chr|chown|chop|chomp|chmod|chdir|caller|bless|binmode|bind|atan2|alarm|accept|abs)(?![a-zA-Z0-9_])"),
|
||||||
|
|
||||||
# quote operator
|
# quote operator
|
||||||
RegionRule(r'quoted', r'q[rqwx]? *\(', lex2.get('null'), r'\)'),
|
RegionRule(r'quoted', r'q[rqwx]? *\(', Grammar, r'\)'),
|
||||||
RegionRule(r'quoted', r'q[rqwx]? *{', lex2.get('null'), r'}'),
|
RegionRule(r'quoted', r'q[rqwx]? *{', Grammar, r'}'),
|
||||||
RegionRule(r'quoted', r'q[rqwx]? *<', lex2.get('null'), r'>'),
|
RegionRule(r'quoted', r'q[rqwx]? *<', Grammar, r'>'),
|
||||||
RegionRule(r'quoted', r'q[rqwx]? *\[', lex2.get('null'), r'\]'),
|
RegionRule(r'quoted', r'q[rqwx]? *\[', Grammar, r'\]'),
|
||||||
RegionRule(r'quoted', r'q[rqwx]? *(?P<delim>[^ #])', lex2.get('null'), r'%(delim)s'),
|
RegionRule(r'quoted', r'q[rqwx]? *(?P<delim>[^ #])', Grammar, r'%(delim)s'),
|
||||||
RegionRule(r'quoted', r'q[rqwx]?#', lex2.get('null'), r'#'),
|
RegionRule(r'quoted', r'q[rqwx]?#', Grammar, r'#'),
|
||||||
|
|
||||||
PatternRule(r'function', r"(?:[a-zA-Z_][a-zA-Z_0-9]*::)*[a-zA-Z_][a-zA-Z_0-9]*(?= *\()"),
|
PatternRule(r'function', r"(?:[a-zA-Z_][a-zA-Z_0-9]*::)*[a-zA-Z_][a-zA-Z_0-9]*(?= *\()"),
|
||||||
PatternRule(r'class', r"(?:[a-zA-Z_][a-zA-Z_0-9]*::)*[a-zA-Z_][a-zA-Z_0-9]*(?=->)"),
|
PatternRule(r'class', r"(?:[a-zA-Z_][a-zA-Z_0-9]*::)*[a-zA-Z_][a-zA-Z_0-9]*(?=->)"),
|
||||||
|
@ -96,7 +94,6 @@ class PerlGrammar(Grammar):
|
||||||
PatternRule(r'operator2', r"(?:xor|or|not|ne|lt|le|gt|ge|eq|cmp|and)(?![a-zA-Z_])"),
|
PatternRule(r'operator2', r"(?:xor|or|not|ne|lt|le|gt|ge|eq|cmp|and)(?![a-zA-Z_])"),
|
||||||
PatternRule(r'bareword', r'(?:[a-zA-Z_][a-zA-Z_0-9]*::)*[a-zA-Z_][a-zA-Z_0-9]*')
|
PatternRule(r'bareword', r'(?:[a-zA-Z_][a-zA-Z_0-9]*::)*[a-zA-Z_][a-zA-Z_0-9]*')
|
||||||
]
|
]
|
||||||
lex2.add('perl', PerlGrammar)
|
|
||||||
|
|
||||||
class PerlTabber(tab2.StackTabber):
|
class PerlTabber(tab2.StackTabber):
|
||||||
def is_base(self, y):
|
def is_base(self, y):
|
||||||
|
@ -165,7 +162,7 @@ class PerlTabber(tab2.StackTabber):
|
||||||
|
|
||||||
class Perl(mode2.Fundamental):
|
class Perl(mode2.Fundamental):
|
||||||
tabbercls = PerlTabber
|
tabbercls = PerlTabber
|
||||||
grammar = lex2.get('perl')
|
grammar = PerlGrammar
|
||||||
opentoken = 'delimiter'
|
opentoken = 'delimiter'
|
||||||
opentags = {'(': ')', '[': ']', '{': '}'}
|
opentags = {'(': ')', '[': ']', '{': '}'}
|
||||||
closetoken = 'delimiter'
|
closetoken = 'delimiter'
|
||||||
|
|
|
@ -9,7 +9,6 @@ class StringGrammar(Grammar):
|
||||||
PatternRule(r'octal', r'\\[0-7]{3}'),
|
PatternRule(r'octal', r'\\[0-7]{3}'),
|
||||||
PatternRule(r'escaped', r'\\.'),
|
PatternRule(r'escaped', r'\\.'),
|
||||||
]
|
]
|
||||||
lex2.grammars['string-py'] = StringGrammar
|
|
||||||
|
|
||||||
class PythonGrammar(Grammar):
|
class PythonGrammar(Grammar):
|
||||||
rules = [
|
rules = [
|
||||||
|
@ -29,14 +28,13 @@ class PythonGrammar(Grammar):
|
||||||
PatternRule(r"integer", r"(?<![\.0-9a-zA-Z_])(?:0|[1-9][0-9]*|0[0-7]+|0[xX][0-9a-fA-F]+)[lL]?(?![\.0-9a-zA-Z_])"),
|
PatternRule(r"integer", r"(?<![\.0-9a-zA-Z_])(?:0|[1-9][0-9]*|0[0-7]+|0[xX][0-9a-fA-F]+)[lL]?(?![\.0-9a-zA-Z_])"),
|
||||||
PatternRule(r"float", r"(?<![\.0-9a-zA-Z_])(?:[0-9]+\.[0-9]*|\.[0-9]+|(?:[0-9]|[0-9]+\.[0-9]*|\.[0-9]+)[eE][\+-]?[0-9]+)(?![\.0-9a-zA-Z_])"),
|
PatternRule(r"float", r"(?<![\.0-9a-zA-Z_])(?:[0-9]+\.[0-9]*|\.[0-9]+|(?:[0-9]|[0-9]+\.[0-9]*|\.[0-9]+)[eE][\+-]?[0-9]+)(?![\.0-9a-zA-Z_])"),
|
||||||
PatternRule(r"imaginary", r"(?<![\.0-9a-zA-Z_])(?:[0-9]+|(?:[0-9]+\.[0-9]*|\.[0-9]+|(?:[0-9]|[0-9]+\.[0-9]*|\.[0-9]+)[eE][\+-]?[0-9]+)[jJ])(?![\.0-9a-zA-Z_])"),
|
PatternRule(r"imaginary", r"(?<![\.0-9a-zA-Z_])(?:[0-9]+|(?:[0-9]+\.[0-9]*|\.[0-9]+|(?:[0-9]|[0-9]+\.[0-9]*|\.[0-9]+)[eE][\+-]?[0-9]+)[jJ])(?![\.0-9a-zA-Z_])"),
|
||||||
RegionRule(r'string', r'"""', lex2.grammars['string-py'], r'"""'),
|
RegionRule(r'string', r'"""', StringGrammar, r'"""'),
|
||||||
RegionRule(r'string', r"'''", lex2.grammars['string-py'], r"'''"),
|
RegionRule(r'string', r"'''", StringGrammar, r"'''"),
|
||||||
RegionRule(r'string', r'"', lex2.grammars['string-py'], r'"'),
|
RegionRule(r'string', r'"', StringGrammar, r'"'),
|
||||||
RegionRule(r'string', r"'", lex2.grammars['string-py'], r"'"),
|
RegionRule(r'string', r"'", StringGrammar, r"'"),
|
||||||
PatternRule(r'comment', r'#.*$'),
|
PatternRule(r'comment', r'#.*$'),
|
||||||
PatternRule(r'continuation', r'\\$'),
|
PatternRule(r'continuation', r'\\$'),
|
||||||
]
|
]
|
||||||
lex2.grammars['python'] = PythonGrammar
|
|
||||||
|
|
||||||
class PythonTabber(tab2.StackTabber):
|
class PythonTabber(tab2.StackTabber):
|
||||||
endlevel_names = ('pass', 'return', 'yield', 'raise', 'break', 'continue')
|
endlevel_names = ('pass', 'return', 'yield', 'raise', 'break', 'continue')
|
||||||
|
@ -166,7 +164,7 @@ class PythonTabber(tab2.StackTabber):
|
||||||
|
|
||||||
class Python(mode2.Fundamental):
|
class Python(mode2.Fundamental):
|
||||||
tabbercls = PythonTabber
|
tabbercls = PythonTabber
|
||||||
grammar = lex2.grammars['python']
|
grammar = PythonGrammar
|
||||||
opentoken = 'delimiter'
|
opentoken = 'delimiter'
|
||||||
opentags = {'(': ')', '[': ']', '{': '}'}
|
opentags = {'(': ')', '[': ']', '{': '}'}
|
||||||
closetoken = 'delimiter'
|
closetoken = 'delimiter'
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import sets, string
|
import re, sets, string
|
||||||
|
|
||||||
import color, method, minibuffer, mode2, search
|
import color, method, minibuffer, mode2, search
|
||||||
from point2 import Point
|
from point2 import Point
|
||||||
|
@ -56,7 +56,13 @@ def _find_next(m, move=False):
|
||||||
s = m.before
|
s = m.before
|
||||||
w = m.old_window
|
w = m.old_window
|
||||||
c = w.logical_cursor()
|
c = w.logical_cursor()
|
||||||
newc = search.find_next(s, w, move, start=c.add(1, 0))
|
try:
|
||||||
|
r = re.compile(search.escape_literal(s))
|
||||||
|
except:
|
||||||
|
(m.p1, m.p2) = (None, None)
|
||||||
|
return False
|
||||||
|
|
||||||
|
newc = search.find_next(r, w, move, start=c.add(1, 0))
|
||||||
if newc:
|
if newc:
|
||||||
(m.p1, m.p2) = newc
|
(m.p1, m.p2) = newc
|
||||||
return True
|
return True
|
||||||
|
|
13
mode_xml.py
13
mode_xml.py
|
@ -3,25 +3,22 @@ from lex2 import Grammar, PatternRule, RegionRule
|
||||||
|
|
||||||
class OpenTagGrammar(Grammar):
|
class OpenTagGrammar(Grammar):
|
||||||
rules = [
|
rules = [
|
||||||
RegionRule(r'string', r'"', lex2.grammars['null'], r'"'),
|
RegionRule(r'string', r'"', Grammar, r'"'),
|
||||||
RegionRule(r'string', r"'", lex2.grammars['null'], r"'"),
|
RegionRule(r'string', r"'", Grammar, r"'"),
|
||||||
PatternRule(r'namespace', r'[a-zA-Z_]+:'),
|
PatternRule(r'namespace', r'[a-zA-Z_]+:'),
|
||||||
PatternRule(r'attrname', r'[^ =>\n]+(?==)'),
|
PatternRule(r'attrname', r'[^ =>\n]+(?==)'),
|
||||||
PatternRule(r'name', r'[^ =>\n]+'),
|
PatternRule(r'name', r'[^ =>\n]+'),
|
||||||
]
|
]
|
||||||
lex2.grammars['xml-opentag'] = OpenTagGrammar
|
|
||||||
|
|
||||||
|
|
||||||
class XMLGrammar(Grammar):
|
class XMLGrammar(Grammar):
|
||||||
rules = [
|
rules = [
|
||||||
RegionRule(r'comment', r'<!--', lex2.grammars['null'], r'-->'),
|
RegionRule(r'comment', r'<!--', Grammar, r'-->'),
|
||||||
RegionRule(r'opentag', r'<', lex2.grammars['xml-opentag'], r'/?>'),
|
RegionRule(r'opentag', r'<', OpenTagGrammar, r'/?>'),
|
||||||
PatternRule(r'closetag', r'< */ *[ =>\n]+ *>'),
|
PatternRule(r'closetag', r'< */ *[ =>\n]+ *>'),
|
||||||
]
|
]
|
||||||
lex2.grammars['xml'] = XMLGrammar
|
|
||||||
|
|
||||||
class XML(mode2.Fundamental):
|
class XML(mode2.Fundamental):
|
||||||
grammar = lex2.grammars['xml']
|
grammar = XMLGrammar
|
||||||
def __init__(self, w):
|
def __init__(self, w):
|
||||||
mode2.Fundamental.__init__(self, w)
|
mode2.Fundamental.__init__(self, w)
|
||||||
self.colors = {
|
self.colors = {
|
||||||
|
|
Loading…
Reference in New Issue