parent
83ef208a0f
commit
5cf1a2843e
139
lex2_perl.py
139
lex2_perl.py
|
@ -3,23 +3,23 @@ from lex2 import Grammar, ConstantRule, PatternRule, ContextPatternRule, RegionR
|
||||||
class PodGrammar(Grammar):
|
class PodGrammar(Grammar):
|
||||||
rules = [
|
rules = [
|
||||||
PatternRule(
|
PatternRule(
|
||||||
name=r'header',
|
name=r'entry',
|
||||||
pattern=r'(?<=^=head[1-4]) +.*$',
|
pattern=r'(?<=^=head[1-4]) +.*$',
|
||||||
),
|
),
|
||||||
PatternRule(
|
PatternRule(
|
||||||
name=r'indent_level',
|
name=r'entry',
|
||||||
pattern=r'(?<=^=over) +.*$',
|
pattern=r'(?<=^=over) +.*$',
|
||||||
),
|
),
|
||||||
PatternRule(
|
PatternRule(
|
||||||
name=r'item_entry',
|
name=r'entry',
|
||||||
pattern=r'(?<=^=item) +.*$',
|
pattern=r'(?<=^=item) +.*$',
|
||||||
),
|
),
|
||||||
PatternRule(
|
PatternRule(
|
||||||
name=r'format',
|
name=r'entry',
|
||||||
pattern=r'(?:(?<=^=begin)|(?<=^=end)) +.*$',
|
pattern=r'(?:(?<=^=begin)|(?<=^=end)) +.*$',
|
||||||
),
|
),
|
||||||
PatternRule(
|
PatternRule(
|
||||||
name=r'encoding_type',
|
name=r'entry',
|
||||||
pattern=r'(?<=^=encoding) +.*$',
|
pattern=r'(?<=^=encoding) +.*$',
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
@ -31,20 +31,20 @@ class StringGrammar(Grammar):
|
||||||
pattern=r'\\.',
|
pattern=r'\\.',
|
||||||
),
|
),
|
||||||
PatternRule(
|
PatternRule(
|
||||||
name=r'hash_deref',
|
name=r'deref',
|
||||||
pattern=r"\$\$*[A-Za-z0-9_](?:[A-Za-z0-9_]|::)*(?:->{(?:[a-zA-Z_][a-zA-Z_0-9]*|'(?:\\.|[^'\\])*'|\"(\\.|[^\\\"])*\")})+",
|
pattern=r"\$\$*[A-Za-z0-9_](?:[A-Za-z0-9_]|::)*(?:->{\$?(?:[a-zA-Z_][a-zA-Z_0-9]*|'(?:\\.|[^'\\])*'|\"(\\.|[^\\\"])*\")}|->\[\$?[0-9a-zA-Z_]+\])+",
|
||||||
),
|
),
|
||||||
PatternRule(
|
PatternRule(
|
||||||
name=r'length_scalar',
|
name=r'length',
|
||||||
pattern=r"\$#[A-Za-z0-9_](?:[A-Za-z0-9_]|::)*",
|
pattern=r"\$#[A-Za-z0-9_](?:[A-Za-z0-9_]|::)*",
|
||||||
),
|
),
|
||||||
ContextPatternRule(
|
ContextPatternRule(
|
||||||
name=r'system_scalar',
|
name=r'scalar',
|
||||||
pattern=r"\$[^A-Za-z0-9 %(delim)s](?![A-Za-z0-9_])",
|
pattern=r"\$[^A-Za-z0-9 %(delim)s](?![A-Za-z0-9_])",
|
||||||
fallback=r"\$[^A-Za-z0-9 ](?![A-Za-z0-9_])",
|
fallback=r"\$[^A-Za-z0-9 ](?![A-Za-z0-9_])",
|
||||||
),
|
),
|
||||||
PatternRule(
|
PatternRule(
|
||||||
name=r'system_array',
|
name=r'array',
|
||||||
pattern=r"@_",
|
pattern=r"@_",
|
||||||
),
|
),
|
||||||
PatternRule(
|
PatternRule(
|
||||||
|
@ -63,12 +63,33 @@ class StringGrammar(Grammar):
|
||||||
|
|
||||||
class PerlGrammar(Grammar):
|
class PerlGrammar(Grammar):
|
||||||
rules = [
|
rules = [
|
||||||
|
# heredocs
|
||||||
RegionRule(
|
RegionRule(
|
||||||
name=r'heredoc',
|
name=r'heredoc1',
|
||||||
start=r"<< *(?P<heredoc>[a-zA-Z0-9_]+) *;",
|
start=r"<<(?P<heredoc>[a-zA-Z0-9_]+) *;",
|
||||||
grammar=StringGrammar(),
|
grammar=StringGrammar(),
|
||||||
end=r'^%(heredoc)s$',
|
end=r'^%(heredoc)s$',
|
||||||
),
|
),
|
||||||
|
RegionRule(
|
||||||
|
name=r'heredoc1',
|
||||||
|
start=r"<< *\"(?P<heredoc>[a-zA-Z0-9_]+)\" *;",
|
||||||
|
grammar=StringGrammar(),
|
||||||
|
end=r'^%(heredoc)s$',
|
||||||
|
),
|
||||||
|
RegionRule(
|
||||||
|
name=r'heredoc2',
|
||||||
|
start=r"<< *'(?P<heredoc>[a-zA-Z0-9_]+)' *;",
|
||||||
|
grammar=Grammar(),
|
||||||
|
end=r'^%(heredoc)s$',
|
||||||
|
),
|
||||||
|
RegionRule(
|
||||||
|
name=r'eval_heredoc',
|
||||||
|
start=r"<< *`(?P<heredoc>[a-zA-Z0-9_]+)` *;",
|
||||||
|
grammar=StringGrammar(),
|
||||||
|
end=r'^%(heredoc)s$',
|
||||||
|
),
|
||||||
|
|
||||||
|
# end block
|
||||||
RegionRule(
|
RegionRule(
|
||||||
name=r'endblock',
|
name=r'endblock',
|
||||||
start=r"^__END__|__DATA__ *$",
|
start=r"^__END__|__DATA__ *$",
|
||||||
|
@ -112,25 +133,29 @@ class PerlGrammar(Grammar):
|
||||||
pattern=r"(?<!->)(?:STDIN|STDERR|STDOUT|and|cmp|continue|do|else|elsif|eq|eval|foreach|for|if|last|my|next|ne|not|or|our|package|require|return|sub|undef|unless|until|use|while)(?![a-zA-Z0-9_])",
|
pattern=r"(?<!->)(?:STDIN|STDERR|STDOUT|and|cmp|continue|do|else|elsif|eq|eval|foreach|for|if|last|my|next|ne|not|or|our|package|require|return|sub|undef|unless|until|use|while)(?![a-zA-Z0-9_])",
|
||||||
),
|
),
|
||||||
PatternRule(
|
PatternRule(
|
||||||
name=r'bareword_hash_index',
|
name=r'hash_key',
|
||||||
pattern=r'(?<={)[A-Za-z0-9_]+(?=})',
|
pattern=r'(?<={)[A-Za-z0-9_]+(?=})',
|
||||||
),
|
),
|
||||||
PatternRule(
|
PatternRule(
|
||||||
name=r'bareword_hash_key',
|
name=r'hash_key',
|
||||||
pattern=r'[A-Za-z0-9_]+(?= *=>)',
|
pattern=r'[A-Za-z0-9_]+(?= *=>)',
|
||||||
),
|
),
|
||||||
PatternRule(
|
PatternRule(
|
||||||
name=r'length_scalar',
|
name=r'length',
|
||||||
pattern=r"\$#[A-Za-z0-9_](?:[A-Za-z0-9_]|::)*",
|
pattern=r"\$#[A-Za-z0-9_](?:[A-Za-z0-9_]|::)*",
|
||||||
),
|
),
|
||||||
PatternRule(
|
PatternRule(
|
||||||
name=r'system_scalar',
|
name=r'scalar',
|
||||||
pattern=r"\$[][><ab/'\"_@\?#\$!%^|&*()](?![A-Za-z0-9_])",
|
pattern=r"\$[][><ab/'\"_@\?#\$!%^|&*()](?![A-Za-z0-9_])",
|
||||||
),
|
),
|
||||||
PatternRule(
|
PatternRule(
|
||||||
name=r'system_array',
|
name=r'array',
|
||||||
pattern=r"@_",
|
pattern=r"@_",
|
||||||
),
|
),
|
||||||
|
PatternRule(
|
||||||
|
name=r'function',
|
||||||
|
pattern=r"\$\$*[A-Za-z0-9_](?:[A-Za-z0-9_]|::)*(?=-> *\()",
|
||||||
|
),
|
||||||
PatternRule(
|
PatternRule(
|
||||||
name=r'scalar',
|
name=r'scalar',
|
||||||
pattern=r"\$\$*[A-Za-z0-9_](?:[A-Za-z0-9_]|::)*",
|
pattern=r"\$\$*[A-Za-z0-9_](?:[A-Za-z0-9_]|::)*",
|
||||||
|
@ -144,41 +169,41 @@ class PerlGrammar(Grammar):
|
||||||
pattern=r"%\$*[A-Za-z_](?:[A-Za-z0-9_]|::)*",
|
pattern=r"%\$*[A-Za-z_](?:[A-Za-z0-9_]|::)*",
|
||||||
),
|
),
|
||||||
PatternRule(
|
PatternRule(
|
||||||
name=r'dereference',
|
name=r'deref',
|
||||||
pattern=r"[@%\$&\*](?={)",
|
pattern=r"[@%\$&\*](?={)",
|
||||||
),
|
),
|
||||||
RegionRule(
|
RegionRule(
|
||||||
name=r'quoted_region1',
|
name=r'quoted',
|
||||||
start=r'q[rqwx]? *(?P<delim>[^ #])',
|
start=r'q[rqwx]? *(?P<delim>[^ #])',
|
||||||
grammar=Grammar(),
|
grammar=Grammar(),
|
||||||
end=r'%(delim)s',
|
end=r'%(delim)s',
|
||||||
),
|
),
|
||||||
RegionRule(
|
RegionRule(
|
||||||
name=r'quoted_region2',
|
name=r'quoted',
|
||||||
start=r'q[rqwx]?#',
|
start=r'q[rqwx]?#',
|
||||||
grammar=Grammar(),
|
grammar=Grammar(),
|
||||||
end=r'#',
|
end=r'#',
|
||||||
),
|
),
|
||||||
RegionRule(
|
RegionRule(
|
||||||
name=r'bracket_quoted_region1',
|
name=r'quoted',
|
||||||
start=r'q[rqwx]? *\(',
|
start=r'q[rqwx]? *\(',
|
||||||
grammar=Grammar(),
|
grammar=Grammar(),
|
||||||
end=r'\)',
|
end=r'\)',
|
||||||
),
|
),
|
||||||
RegionRule(
|
RegionRule(
|
||||||
name=r'bracket_quoted_region2',
|
name=r'quoted',
|
||||||
start=r'q[rqwx]? *{',
|
start=r'q[rqwx]? *{',
|
||||||
grammar=Grammar(),
|
grammar=Grammar(),
|
||||||
end=r'}',
|
end=r'}',
|
||||||
),
|
),
|
||||||
RegionRule(
|
RegionRule(
|
||||||
name=r'bracket_quoted_region3',
|
name=r'quoted',
|
||||||
start=r'q[rqwx]? *<',
|
start=r'q[rqwx]? *<',
|
||||||
grammar=Grammar(),
|
grammar=Grammar(),
|
||||||
end=r'>',
|
end=r'>',
|
||||||
),
|
),
|
||||||
RegionRule(
|
RegionRule(
|
||||||
name=r'bracket_quoted_region4',
|
name=r'quoted',
|
||||||
start=r'q[rqwx]? *\[',
|
start=r'q[rqwx]? *\[',
|
||||||
grammar=Grammar(),
|
grammar=Grammar(),
|
||||||
end=r'\]',
|
end=r'\]',
|
||||||
|
@ -186,19 +211,19 @@ class PerlGrammar(Grammar):
|
||||||
|
|
||||||
# match regexes
|
# match regexes
|
||||||
RegionRule(
|
RegionRule(
|
||||||
name=r'match_regex1',
|
name=r'match',
|
||||||
start=r'(?:(?<==~)|(?<=!~)|(?<=\()) *(?P<delim>/)',
|
start=r'(?:(?<==~)|(?<=!~)|(?<=\()) *(?P<delim>/)',
|
||||||
grammar=StringGrammar(),
|
grammar=StringGrammar(),
|
||||||
end=r'/[a-z]*',
|
end=r'/[a-z]*',
|
||||||
),
|
),
|
||||||
RegionRule(
|
RegionRule(
|
||||||
name=r'match_regex2',
|
name=r'match',
|
||||||
start=r'm *(?P<delim>[^ #a-zA-Z0-9_])',
|
start=r'm *(?P<delim>[^ #a-zA-Z0-9_])',
|
||||||
grammar=StringGrammar(),
|
grammar=StringGrammar(),
|
||||||
end=r'%(delim)s[a-z]*',
|
end=r'%(delim)s[a-z]*',
|
||||||
),
|
),
|
||||||
RegionRule(
|
RegionRule(
|
||||||
name=r'match_regex3',
|
name=r'match',
|
||||||
start=r'm(?P<delim>#)',
|
start=r'm(?P<delim>#)',
|
||||||
grammar=StringGrammar(),
|
grammar=StringGrammar(),
|
||||||
end=r'#[a-z]*',
|
end=r'#[a-z]*',
|
||||||
|
@ -206,7 +231,7 @@ class PerlGrammar(Grammar):
|
||||||
|
|
||||||
# replace regexes
|
# replace regexes
|
||||||
DualRegionRule(
|
DualRegionRule(
|
||||||
name=r'replace_regex1',
|
name=r'replace',
|
||||||
start=r's *(?P<delim>[^ a-zA-Z0-9_])',
|
start=r's *(?P<delim>[^ a-zA-Z0-9_])',
|
||||||
grammar1=StringGrammar(),
|
grammar1=StringGrammar(),
|
||||||
middle=r'%(delim)s',
|
middle=r'%(delim)s',
|
||||||
|
@ -214,21 +239,39 @@ class PerlGrammar(Grammar):
|
||||||
end=r'%(delim)s[a-z]*',
|
end=r'%(delim)s[a-z]*',
|
||||||
),
|
),
|
||||||
DualRegionRule(
|
DualRegionRule(
|
||||||
name=r'replace_regex2',
|
name=r'replace',
|
||||||
start=r's#',
|
start=r's(?P<delim>#)',
|
||||||
grammar1=StringGrammar(),
|
grammar1=StringGrammar(),
|
||||||
middle=r'#',
|
middle=r'#',
|
||||||
grammar2=StringGrammar(),
|
grammar2=StringGrammar(),
|
||||||
end=r'#[a-z]*',
|
end=r'#[a-z]*',
|
||||||
),
|
),
|
||||||
|
|
||||||
|
# translate operator
|
||||||
|
DualRegionRule(
|
||||||
|
name=r'translate',
|
||||||
|
start=r'(?:y|tr) *(?P<delim>[^ a-zA-Z0-9_])',
|
||||||
|
grammar1=Grammar(),
|
||||||
|
middle=r'%(delim)s',
|
||||||
|
grammar2=Grammar(),
|
||||||
|
end=r'%(delim)s[a-z]*',
|
||||||
|
),
|
||||||
|
DualRegionRule(
|
||||||
|
name=r'translate',
|
||||||
|
start=r'(?:y|tr)#',
|
||||||
|
grammar1=Grammar(),
|
||||||
|
middle=r'#',
|
||||||
|
grammar2=Grammar(),
|
||||||
|
end=r'#[a-z]*',
|
||||||
|
),
|
||||||
|
|
||||||
|
# some more basic stuff
|
||||||
PatternRule(
|
PatternRule(
|
||||||
name=r'package',
|
name=r'package',
|
||||||
pattern=r"(?<=package )(?:[a-zA-Z_][a-zA-Z_0-9]*::)*[a-zA-Z_][a-zA-Z_0-9]*",
|
pattern=r"(?<=package )(?:[a-zA-Z_][a-zA-Z_0-9]*::)*[a-zA-Z_][a-zA-Z_0-9]*",
|
||||||
),
|
),
|
||||||
PatternRule(
|
PatternRule(
|
||||||
name=r'sub',
|
name=r'sub',
|
||||||
#pattern=r"(?<=sub )[a-zA-Z_][a-zA-Z_0-9]*(?= *{)",
|
|
||||||
pattern=r"(?<=sub )[a-zA-Z_][a-zA-Z_0-9]*",
|
pattern=r"(?<=sub )[a-zA-Z_][a-zA-Z_0-9]*",
|
||||||
),
|
),
|
||||||
PatternRule(
|
PatternRule(
|
||||||
|
@ -240,33 +283,27 @@ class PerlGrammar(Grammar):
|
||||||
pattern=r'[a-zA-Z_][a-zA-Z0-9_]*:(?!:)',
|
pattern=r'[a-zA-Z_][a-zA-Z0-9_]*:(?!:)',
|
||||||
),
|
),
|
||||||
PatternRule(
|
PatternRule(
|
||||||
name=r'instance_method',
|
name=r'method',
|
||||||
pattern=r"(?<=->)[a-zA-Z_][a-zA-Z_0-9]*",
|
pattern=r"(?<=->)[a-zA-Z_][a-zA-Z_0-9]*",
|
||||||
),
|
),
|
||||||
PatternRule(
|
PatternRule(
|
||||||
name=r'static_method',
|
name=r'function',
|
||||||
pattern=r"&?(?:[a-zA-Z_][a-zA-Z_0-9]*::)+[a-zA-Z_][a-zA-Z_0-9]*",
|
pattern=r"&\$*(?:[a-zA-Z_][a-zA-Z_0-9]*::)*[a-zA-Z_][a-zA-Z_0-9]*",
|
||||||
),
|
),
|
||||||
PatternRule(
|
PatternRule(
|
||||||
name=r'builtin_method',
|
name=r'function',
|
||||||
|
pattern=r"(?:[a-zA-Z_][a-zA-Z_0-9]*::)*[a-zA-Z_][a-zA-Z_0-9]*(?= *\()",
|
||||||
|
),
|
||||||
|
PatternRule(
|
||||||
|
name=r'builtin',
|
||||||
pattern=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_])",
|
pattern=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(
|
PatternRule(
|
||||||
name=r'method',
|
name=r'class',
|
||||||
pattern=r"&(?:[a-zA-Z_][a-zA-Z_0-9]*::)*[a-zA-Z_][a-zA-Z_0-9]*",
|
pattern=r"(?:[a-zA-Z_][a-zA-Z_0-9]*::)*[a-zA-Z_][a-zA-Z_0-9]*",
|
||||||
),
|
),
|
||||||
PatternRule(
|
|
||||||
name=r'ref_method',
|
# nested regions
|
||||||
pattern=r"&\$(?:[a-zA-Z_][a-zA-Z_0-9]*::)*[a-zA-Z_][a-zA-Z_0-9]*",
|
|
||||||
),
|
|
||||||
PatternRule(
|
|
||||||
name=r'bareword_method',
|
|
||||||
pattern=r"(?:[a-zA-Z_][a-zA-Z_0-9]*::)*[a-zA-Z_][a-zA-Z_0-9]*(?= *\()",
|
|
||||||
),
|
|
||||||
#PatternRule(
|
|
||||||
# name=r'delimiter',
|
|
||||||
# pattern=r"\(|\)|\[|\]|{|}|,|;|->|=>|=|\?|(?<!:):(?!=:)",
|
|
||||||
#),
|
|
||||||
RegionRule(
|
RegionRule(
|
||||||
name=r'paren',
|
name=r'paren',
|
||||||
start=r'\(',
|
start=r'\(',
|
||||||
|
@ -285,12 +322,14 @@ class PerlGrammar(Grammar):
|
||||||
grammar=None,
|
grammar=None,
|
||||||
end=r'\]',
|
end=r'\]',
|
||||||
),
|
),
|
||||||
|
|
||||||
|
# some basic stuff
|
||||||
PatternRule(
|
PatternRule(
|
||||||
name=r'delimiter',
|
name=r'delimiter',
|
||||||
pattern=r",|;|->|=>|=|\?|(?<!:):(?!=:)",
|
pattern=r",|;|->|=>|=|\?|(?<!:):(?!=:)",
|
||||||
),
|
),
|
||||||
PatternRule(
|
PatternRule(
|
||||||
name=r'unary_operator',
|
name=r'operator',
|
||||||
pattern=r"\+=|-=|\*=|/=|//=|%=|&=\|\^=|>>=|<<=|\*\*=",
|
pattern=r"\+=|-=|\*=|/=|//=|%=|&=\|\^=|>>=|<<=|\*\*=",
|
||||||
),
|
),
|
||||||
PatternRule(
|
PatternRule(
|
||||||
|
|
159
test3.py
159
test3.py
|
@ -17,99 +17,86 @@ for i in range(0, len(color_list)):
|
||||||
color_dict[color_names[i]] = color_list[i]
|
color_dict[color_names[i]] = color_list[i]
|
||||||
|
|
||||||
token_colors = {
|
token_colors = {
|
||||||
'escaped': 'lpurple',
|
# basic stuff
|
||||||
'null': 'white',
|
'escaped': 'lpurple',
|
||||||
'delimiter': 'white',
|
'null': 'white',
|
||||||
'pod.start': 'lred',
|
'delimiter': 'white',
|
||||||
'pod.null': 'lred',
|
'sub': 'lcyan',
|
||||||
'pod.end': 'lred',
|
'number': 'white',
|
||||||
'pod.header': 'lpurple',
|
'operator': 'white',
|
||||||
'pod.indent_level': 'lpurple',
|
'endblock': 'lred',
|
||||||
'pod.item_entry': 'lpurple',
|
'keyword': 'lpurple',
|
||||||
'pod.format': 'lpurple',
|
'scalar': 'yellow',
|
||||||
'pod.encoding_type': 'lpurple',
|
'array': 'yellow',
|
||||||
'sub': 'lcyan',
|
'deref': 'yellow',
|
||||||
'number': 'white',
|
'hash': 'yellow',
|
||||||
'operator': 'white',
|
'hash_key': 'lgreen',
|
||||||
'heredoc': 'lgreen',
|
'comment': 'lred',
|
||||||
'endblock': 'lred',
|
'function': 'lcyan',
|
||||||
'pod': 'lred',
|
'builtin': 'lpurple',
|
||||||
'comment': 'lred',
|
'method': 'lcyan',
|
||||||
#'string1': 'lgreen',
|
'bareword': 'white',
|
||||||
'string1.start': 'lgreen',
|
'label': 'lcyan',
|
||||||
'string1.null': 'lgreen',
|
'package': 'lcyan',
|
||||||
'string1.escaped': 'lpurple',
|
'class': 'lcyan',
|
||||||
#'string1.scalar': 'yellow',
|
'use': 'lcyan',
|
||||||
#'string1.system_scalar': 'yellow',
|
'method': 'lcyan',
|
||||||
'string1.hash_deref': 'yellow',
|
|
||||||
#'string1.hash_bareword_index': 'lgreen',
|
# heredoc
|
||||||
'string1.end': 'lgreen',
|
'heredoc1.start': 'lgreen',
|
||||||
#'string2': 'lgreen',
|
'heredoc1.null': 'lgreen',
|
||||||
'string2.start': 'lgreen',
|
'heredoc1.end': 'lgreen',
|
||||||
'string2.null': 'lgreen',
|
'heredoc2.start': 'lgreen',
|
||||||
'string2.end': 'lgreen',
|
'heredoc2.null': 'lgreen',
|
||||||
'evalstring': 'lcyan',
|
'heredoc2.end': 'lgreen',
|
||||||
'default_string': 'lgreen',
|
'eval_heredoc.start': 'lcyan',
|
||||||
'keyword': 'lpurple',
|
'eval_heredoc.null': 'lcyan',
|
||||||
'length_scalar': 'yellow',
|
'eval_heredoc.end': 'lcyan',
|
||||||
'system_scalar': 'yellow',
|
|
||||||
'system_array': 'yellow',
|
# pod
|
||||||
'scalar': 'yellow',
|
'pod.start': 'lred',
|
||||||
'dereference': 'yellow',
|
'pod.null': 'lred',
|
||||||
'array': 'yellow',
|
'pod.entry': 'lpurple',
|
||||||
'hash': 'yellow',
|
'pod.end': 'lred',
|
||||||
'bareword_hash_index': 'lgreen',
|
|
||||||
|
# "" strings
|
||||||
|
'string1.start': 'lgreen',
|
||||||
|
'string1.null': 'lgreen',
|
||||||
|
'string1.escaped': 'lpurple',
|
||||||
|
'string1.deref': 'yellow',
|
||||||
|
'string1.end': 'lgreen',
|
||||||
|
|
||||||
|
# '' strings
|
||||||
|
'string2.start': 'lgreen',
|
||||||
|
'string2.null': 'lgreen',
|
||||||
|
'string2.end': 'lgreen',
|
||||||
|
|
||||||
|
# `` strings
|
||||||
|
'evalstring': 'lcyan',
|
||||||
|
|
||||||
# quoted region
|
# quoted region
|
||||||
'quoted_region1': 'lcyan',
|
'quoted': 'lcyan',
|
||||||
'quoted_region1.start': 'lcyan',
|
'quoted.start': 'lcyan',
|
||||||
'quoted_region1.null': 'lcyan',
|
'quoted.null': 'lcyan',
|
||||||
'quoted_region1.end': 'lcyan',
|
'quoted.end': 'lcyan',
|
||||||
'quoted_region2': 'lcyan',
|
|
||||||
'quoted_region2.start': 'lcyan',
|
|
||||||
'quoted_region2.null': 'lcyan',
|
|
||||||
'quoted_region2.end': 'lcyan',
|
|
||||||
|
|
||||||
# match regex
|
# match regex
|
||||||
'match_regex1.start': 'lcyan',
|
'match.start': 'lcyan',
|
||||||
'match_regex1.end': 'lcyan',
|
'match.end': 'lcyan',
|
||||||
'match_regex1.null': 'lcyan',
|
'match.null': 'lcyan',
|
||||||
'match_regex2.start': 'lcyan',
|
|
||||||
'match_regex2.end': 'lcyan',
|
|
||||||
'match_regex2.null': 'lcyan',
|
|
||||||
'match_regex3.start': 'lcyan',
|
|
||||||
'match_regex3.end': 'lcyan',
|
|
||||||
'match_regex3.null': 'lcyan',
|
|
||||||
|
|
||||||
# replace regex
|
# replace regex
|
||||||
'replace_regex1.start': 'lcyan',
|
'replace.start': 'lcyan',
|
||||||
'replace_regex1.middle': 'lcyan',
|
'replace.middle': 'lcyan',
|
||||||
'replace_regex1.end': 'lcyan',
|
'replace.end': 'lcyan',
|
||||||
'replace_regex1.null': 'lcyan',
|
'replace.null': 'lcyan',
|
||||||
'replace_regex2.start': 'lcyan',
|
|
||||||
'replace_regex2.middle': 'lcyan',
|
# translate regex
|
||||||
'replace_regex2.end': 'lcyan',
|
'translate.start': 'lpurple',
|
||||||
'replace_regex2.null': 'lcyan',
|
'translate.middle': 'lpurple',
|
||||||
|
'translate.end': 'lpurple',
|
||||||
|
'translate.null': 'lpurple',
|
||||||
|
|
||||||
#
|
|
||||||
'bareword_hash_key': 'lgreen',
|
|
||||||
'interpolated_scalar': 'yellow',
|
|
||||||
'interpolated_system_scalar': 'yellow',
|
|
||||||
'interpolated_array': 'yellow',
|
|
||||||
'interpolated_system_array': 'yellow',
|
|
||||||
'interpolated_hash': 'yellow',
|
|
||||||
'label': 'lcyan',
|
|
||||||
'package': 'lcyan',
|
|
||||||
'use': 'lcyan',
|
|
||||||
'method': 'lcyan',
|
|
||||||
'methodref': 'lcyan',
|
|
||||||
'method_declaration': 'lcyan',
|
|
||||||
'instance_method': 'lcyan',
|
|
||||||
'static_method': 'lcyan',
|
|
||||||
'builtin_method': 'lpurple',
|
|
||||||
'bareword_method': 'lcyan',
|
|
||||||
#'bareword': 'yellow',
|
|
||||||
'bizzaro': 'lpurple',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
paths = sys.argv[1:]
|
paths = sys.argv[1:]
|
||||||
|
|
Loading…
Reference in New Issue