diff options
-rw-r--r-- | lexers/LexPerl.cxx | 2 | ||||
-rw-r--r-- | lexilla/test/examples/perl/perl-test-5220delta.pl.styled | 220 | ||||
-rw-r--r-- | lexilla/test/examples/perl/perl-test-sub-prototypes.pl.styled | 324 | ||||
-rw-r--r-- | test/examples/perl-test-5220delta.pl.styled | 220 | ||||
-rw-r--r-- | test/examples/perl-test-sub-prototypes.pl.styled | 324 |
5 files changed, 545 insertions, 545 deletions
diff --git a/lexers/LexPerl.cxx b/lexers/LexPerl.cxx index f01d26ba4..705463991 100644 --- a/lexers/LexPerl.cxx +++ b/lexers/LexPerl.cxx @@ -905,7 +905,7 @@ void SCI_METHOD LexerPerl::Lex(Sci_PositionU startPos, Sci_Position length, int sc.SetState(SCE_PL_DEFAULT); break; case SCE_PL_COMMENTLINE: - if (sc.atLineEnd) { + if (sc.atLineStart) { sc.SetState(SCE_PL_DEFAULT); } break; diff --git a/lexilla/test/examples/perl/perl-test-5220delta.pl.styled b/lexilla/test/examples/perl/perl-test-5220delta.pl.styled index 3754c8929..4a763a47a 100644 --- a/lexilla/test/examples/perl/perl-test-5220delta.pl.styled +++ b/lexilla/test/examples/perl/perl-test-5220delta.pl.styled @@ -1,82 +1,82 @@ -{2}# -*- coding: utf-8 -*-{0} -{2}#--------------------------------------------------------------------------{0} -{2}# perl-test-5220delta.pl{0} -{2}#--------------------------------------------------------------------------{0} -{2}# REF: https://metacpan.org/pod/distribution/perl/pod/perldelta.pod{0} -{2}# maybe future ref: https://metacpan.org/pod/distribution/perl/pod/perl5220delta.pod{0} -{2}# also: http://perltricks.com/article/165/2015/4/10/A-preview-of-Perl-5-22{0} -{2}#{0} -{2}#--------------------------------------------------------------------------{0} -{2}# Kein-Hong Man <keinhong@gmail.com> Public Domain 20151217{0} -{2}#--------------------------------------------------------------------------{0} -{2}# 20151217 initial document{0} -{2}# 20151218 updated tests and comments{0} -{2}#--------------------------------------------------------------------------{0} - -{5}use{0} {6}v5.22{10};{0} {2}# may be needed{0} - -{2}#--------------------------------------------------------------------------{0} -{2}# New bitwise operators{0} -{2}#--------------------------------------------------------------------------{0} - -{5}use{0} {11}feature{0} {7}'bitwise'{0} {2}# enable feature, warning enabled{0} -{5}use{0} {11}experimental{0} {6}"bitwise"{10};{0} {2}# enable feature, warning disabled{0} - -{2}# numerical operands{0} +{2}# -*- coding: utf-8 -*- +#-------------------------------------------------------------------------- +# perl-test-5220delta.pl +#-------------------------------------------------------------------------- +# REF: https://metacpan.org/pod/distribution/perl/pod/perldelta.pod +# maybe future ref: https://metacpan.org/pod/distribution/perl/pod/perl5220delta.pod +# also: http://perltricks.com/article/165/2015/4/10/A-preview-of-Perl-5-22 +# +#-------------------------------------------------------------------------- +# Kein-Hong Man <keinhong@gmail.com> Public Domain 20151217 +#-------------------------------------------------------------------------- +# 20151217 initial document +# 20151218 updated tests and comments +#-------------------------------------------------------------------------- +{0} +{5}use{0} {6}v5.22{10};{0} {2}# may be needed +{0} +{2}#-------------------------------------------------------------------------- +# New bitwise operators +#-------------------------------------------------------------------------- +{0} +{5}use{0} {11}feature{0} {7}'bitwise'{0} {2}# enable feature, warning enabled +{5}use{0} {11}experimental{0} {6}"bitwise"{10};{0} {2}# enable feature, warning disabled +{0} +{2}# numerical operands {4}10{10}&{4}20{0} {4}10{10}|{4}20{0} {4}10{10}^{4}20{0} {10}~{4}10{0} {12}$a{10}&{6}"8"{0} {12}$a{10}|{6}"8"{0} {12}$a{10}^{6}"8"{0} {10}~{12}$a{0} {10}~{6}"8"{0} -{2}# string operands{0} +{2}# string operands {7}'0'{10}&.{6}"8"{0} {7}'0'{10}|.{6}"8"{0} {7}'0'{10}^.{6}"8"{0} {10}~.{7}'0'{0} {10}~.{6}"8"{0} -{2}# the following is AMBIGUOUS, perl sees 10 and not .10 only when bitwise feature is enabled{0} -{2}# so it's feature-setting-dependent, no plans to change current behaviour{0} - {12}$a{10}&{4}.10{0} {12}$a{10}|{4}.10{0} {12}$a{10}^{4}.10{0} {10}~.{12}$a{0} {10}~{4}.10{0} +{2}# the following is AMBIGUOUS, perl sees 10 and not .10 only when bitwise feature is enabled +# so it's feature-setting-dependent, no plans to change current behaviour +{0} {12}$a{10}&{4}.10{0} {12}$a{10}|{4}.10{0} {12}$a{10}^{4}.10{0} {10}~.{12}$a{0} {10}~{4}.10{0} -{2}# assignment variants{0} +{2}# assignment variants {12}$a{10}&={4}10{10};{0} {12}$a{10}|={4}10{10};{0} {12}$a{10}^={4}10{10};{0} {12}$b{10}&.={7}'20'{10};{0} {12}$b{10}|.={7}'20'{10};{0} {12}$b{10}^.={7}'20'{10};{0} {12}$c{10}&={6}"30"{10};{0} {12}$c{10}|={6}"30"{10};{0} {12}$c{10}^={6}"30"{10};{0} {12}$d{10}&.={12}$e{10};{0} {12}$d{10}|.={12}$e{10};{0} {12}$d{10}^.={12}$e{10};{0} -{2}#--------------------------------------------------------------------------{0} -{2}# New double-diamond operator{0} -{2}#--------------------------------------------------------------------------{0} -{2}# <<>> is like <> but each element of @ARGV will be treated as an actual file name{0} - -{2}# example snippet from brian d foy's blog post{0} -{5}while{10}({0} {10}<<>>{0} {10}){0} {10}{{0} {2}# new, safe line input operator{0} - {10}...;{0} +{2}#-------------------------------------------------------------------------- +# New double-diamond operator +#-------------------------------------------------------------------------- +# <<>> is like <> but each element of @ARGV will be treated as an actual file name +{0} +{2}# example snippet from brian d foy's blog post +{5}while{10}({0} {10}<<>>{0} {10}){0} {10}{{0} {2}# new, safe line input operator +{0} {10}...;{0} {10}}{0} -{2}#--------------------------------------------------------------------------{0} -{2}# New \b boundaries in regular expressions{0} -{2}#--------------------------------------------------------------------------{0} - +{2}#-------------------------------------------------------------------------- +# New \b boundaries in regular expressions +#-------------------------------------------------------------------------- +{0} {29}qr/\b{gcb}/{0} {29}qr/\b{wb}/{0} {29}qr/\b{sb}/{0} -{2}#--------------------------------------------------------------------------{0} -{2}# Non-Capturing Regular Expression Flag{0} -{2}#--------------------------------------------------------------------------{0} -{2}# disables capturing and filling in $1, $2, etc{0} - -{6}"hello"{0} {10}=~{0} {17}/(hi|hello)/n{10};{0} {2}# $1 is not set{0} - -{2}#--------------------------------------------------------------------------{0} -{2}# Aliasing via reference{0} -{2}#--------------------------------------------------------------------------{0} -{2}# Variables and subroutines can now be aliased by assigning to a reference{0} - +{2}#-------------------------------------------------------------------------- +# Non-Capturing Regular Expression Flag +#-------------------------------------------------------------------------- +# disables capturing and filling in $1, $2, etc +{0} +{6}"hello"{0} {10}=~{0} {17}/(hi|hello)/n{10};{0} {2}# $1 is not set +{0} +{2}#-------------------------------------------------------------------------- +# Aliasing via reference +#-------------------------------------------------------------------------- +# Variables and subroutines can now be aliased by assigning to a reference +{0} {10}\{12}$c{0} {10}={0} {10}\{12}$d{10};{0} {10}\&{11}x{0} {10}={0} {10}\&{11}y{10};{0} -{2}# Aliasing can also be applied to foreach iterator variables{0} - +{2}# Aliasing can also be applied to foreach iterator variables +{0} {5}foreach{0} {10}\{14}%hash{0} {10}({13}@array_of_hash_refs{10}){0} {10}{{0} {10}...{0} {10}}{0} -{2}# example snippet from brian d foy's blog post{0} - +{2}# example snippet from brian d foy's blog post +{0} {5}use{0} {11}feature{0} {30}qw(refaliasing){10};{0} {10}\{14}%other_hash{0} {10}={0} {10}\{14}%hash{10};{0} @@ -84,24 +84,24 @@ {5}use{0} {6}v5.22{10};{0} {5}use{0} {11}feature{0} {30}qw(refaliasing){10};{0} -{5}foreach{0} {10}\{5}my{0} {14}%hash{0} {10}({0} {13}@array_of_hashes{0} {10}){0} {10}{{0} {2}# named hash control variable{0} - {5}foreach{0} {5}my{0} {12}$key{0} {10}({0} {5}keys{0} {14}%hash{0} {10}){0} {10}{{0} {2}# named hash now!{0} - {10}...;{0} +{5}foreach{0} {10}\{5}my{0} {14}%hash{0} {10}({0} {13}@array_of_hashes{0} {10}){0} {10}{{0} {2}# named hash control variable +{0} {5}foreach{0} {5}my{0} {12}$key{0} {10}({0} {5}keys{0} {14}%hash{0} {10}){0} {10}{{0} {2}# named hash now! +{0} {10}...;{0} {10}}{0} {10}}{0} -{2}#--------------------------------------------------------------------------{0} -{2}# New :const subroutine attribute{0} -{2}#--------------------------------------------------------------------------{0} - +{2}#-------------------------------------------------------------------------- +# New :const subroutine attribute +#-------------------------------------------------------------------------- +{0} {5}my{0} {12}$x{0} {10}={0} {4}54321{10};{0} {15}*INLINED{0} {10}={0} {5}sub{0} {10}:{0} {11}const{0} {10}{{0} {12}$x{0} {10}};{0} {12}$x{10}++;{0} -{2}# more examples of attributes{0} -{2}# (not 5.22 stuff, but some general examples for study, useful for{0} -{2}# handling subroutine signature and subroutine prototype highlighting){0} - +{2}# more examples of attributes +# (not 5.22 stuff, but some general examples for study, useful for +# handling subroutine signature and subroutine prototype highlighting) +{0} {5}sub{0} {11}foo{0} {10}:{0} {11}lvalue{0} {10};{0} {5}package{0} {11}X{10};{0} @@ -114,30 +114,30 @@ {5}package{0} {11}Z{10};{0} {5}sub{0} {11}Y{10}::{11}bar{0} {10}:{0} {11}lvalue{0} {10};{0} -{2}# built-in attributes for subroutines:{0} +{2}# built-in attributes for subroutines: {11}lvalue{0} {11}method{0} {5}prototype{10}(..){0} {11}locked{0} {11}const{0} -{2}#--------------------------------------------------------------------------{0} -{2}# Repetition in list assignment{0} -{2}#--------------------------------------------------------------------------{0} - -{2}# example snippet from brian d foy's blog post{0} +{2}#-------------------------------------------------------------------------- +# Repetition in list assignment +#-------------------------------------------------------------------------- +{0} +{2}# example snippet from brian d foy's blog post {5}use{0} {6}v5.22{10};{0} {5}my{10}({5}undef{10},{0} {12}$card_num{10},{0} {10}({5}undef{10})x{4}3{10},{0} {12}$count{10}){0} {10}={0} {5}split{0} {17}/:/{10};{0} {10}({5}undef{10},{5}undef{10},{12}$foo{10}){0} {10}={0} {11}that_function{10}(){0} -{2}# is equivalent to {0} +{2}# is equivalent to {10}(({5}undef{10})x{4}2{10},{0} {12}$foo{10}){0} {10}={0} {11}that_function{10}(){0} -{2}#--------------------------------------------------------------------------{0} -{2}# Floating point parsing has been improved{0} -{2}#--------------------------------------------------------------------------{0} -{2}# Hexadecimal floating point literals{0} - -{2}# some hex floats from a program by Rick Regan{0} -{2}# appropriated and extended from Lua 5.2.x test cases{0} -{2}# tested on perl 5.22/cygwin{0} - +{2}#-------------------------------------------------------------------------- +# Floating point parsing has been improved +#-------------------------------------------------------------------------- +# Hexadecimal floating point literals +{0} +{2}# some hex floats from a program by Rick Regan +# appropriated and extended from Lua 5.2.x test cases +# tested on perl 5.22/cygwin +{0} {4}0x1p-1074{10};{0} {4}0x3.3333333333334p-5{10};{0} {4}0xcc.ccccccccccdp-11{10};{0} @@ -149,30 +149,30 @@ {4}0X1.921FB4D12D84AP+1{10};{0} {4}0x1.999999999999ap-4{10};{0} -{2}# additional test cases for characterization{0} -{4}0x1p-1074{10}.{0} {2}# dot is a string operator{0} -{4}0x.ABCDEFp10{0} {2}# legal, dot immediately after 0x{0} -{4}0x{10}.{11}p10{0} {2}# perl allows 0x as a zero, then concat with p10 bareword{0} -{4}0x{10}.{11}p{0} {4}0x0{10}.{11}p{0} {2}# dot then bareword{0} -{4}0x_0_.A_BC___DEF_p1_0{0} {2}# legal hex float, underscores are mostly allowed{0} -{4}0x0{10}.{11}_ABCDEFp10{0} {2}# _ABCDEFp10 is a bareword, no underscore allowed after dot{0} - -{2}# illegal, but does not use error highlighting{0} -{4}0x0p1{11}ABC{0} {2}# illegal, highlighted as 0x0p1 abut with bareword ABC {0} - -{2}# allowed to FAIL for now{0} -{4}0x0.ABCDEFp_10{0} {2}# ABCDEFp_10 is a bareword, '_10' exponent not allowed{0} -{4}0xp{0} {4}0xp1{0} {4}0x0.0p{0} {2}# syntax errors{0} -{4}0x41.65{10}.{4}65{0} {2}# hex dot number, but lexer now fails with 0x41.65 left as a partial hex float{0} - -{2}#--------------------------------------------------------------------------{0} -{2}# Support for ?PATTERN? without explicit operator has been removed{0} -{2}#--------------------------------------------------------------------------{0} -{2}# ?PATTERN? must now be written as m?PATTERN?{0} - -{10}?{11}PATTERN{10}?{0} {2}# does not work in current LexPerl anyway, NO ACTION NEEDED{0} +{2}# additional test cases for characterization +{4}0x1p-1074{10}.{0} {2}# dot is a string operator +{4}0x.ABCDEFp10{0} {2}# legal, dot immediately after 0x +{4}0x{10}.{11}p10{0} {2}# perl allows 0x as a zero, then concat with p10 bareword +{4}0x{10}.{11}p{0} {4}0x0{10}.{11}p{0} {2}# dot then bareword +{4}0x_0_.A_BC___DEF_p1_0{0} {2}# legal hex float, underscores are mostly allowed +{4}0x0{10}.{11}_ABCDEFp10{0} {2}# _ABCDEFp10 is a bareword, no underscore allowed after dot +{0} +{2}# illegal, but does not use error highlighting +{4}0x0p1{11}ABC{0} {2}# illegal, highlighted as 0x0p1 abut with bareword ABC +{0} +{2}# allowed to FAIL for now +{4}0x0.ABCDEFp_10{0} {2}# ABCDEFp_10 is a bareword, '_10' exponent not allowed +{4}0xp{0} {4}0xp1{0} {4}0x0.0p{0} {2}# syntax errors +{4}0x41.65{10}.{4}65{0} {2}# hex dot number, but lexer now fails with 0x41.65 left as a partial hex float +{0} +{2}#-------------------------------------------------------------------------- +# Support for ?PATTERN? without explicit operator has been removed +#-------------------------------------------------------------------------- +# ?PATTERN? must now be written as m?PATTERN? +{0} +{10}?{11}PATTERN{10}?{0} {2}# does not work in current LexPerl anyway, NO ACTION NEEDED {17}m?PATTERN?{0} -{2}#--------------------------------------------------------------------------{0} -{2}# end of test file{0} -{2}#--------------------------------------------------------------------------{0} +{2}#-------------------------------------------------------------------------- +# end of test file +#-------------------------------------------------------------------------- diff --git a/lexilla/test/examples/perl/perl-test-sub-prototypes.pl.styled b/lexilla/test/examples/perl/perl-test-sub-prototypes.pl.styled index 96d578846..e7290803b 100644 --- a/lexilla/test/examples/perl/perl-test-sub-prototypes.pl.styled +++ b/lexilla/test/examples/perl/perl-test-sub-prototypes.pl.styled @@ -1,190 +1,190 @@ -{2}# -*- coding: utf-8 -*-{0} -{2}#--------------------------------------------------------------------------{0} -{2}# perl-test-sub-prototypes.pl{0} -{2}#--------------------------------------------------------------------------{0} -{2}# compiled all relevant subroutine prototype test cases{0} -{2}#{0} -{2}#--------------------------------------------------------------------------{0} -{2}# Kein-Hong Man <keinhong@gmail.com> Public Domain{0} -{2}#--------------------------------------------------------------------------{0} -{2}# 20151227 initial document{0} -{2}#--------------------------------------------------------------------------{0} - -{2}#--------------------------------------------------------------------------{0} -{2}# test cases for sub syntax scanner{0} -{2}#--------------------------------------------------------------------------{0} -{2}# sub syntax: simple and with added module notation{0} -{2}#--------------------------------------------------------------------------{0} - +{2}# -*- coding: utf-8 -*- +#-------------------------------------------------------------------------- +# perl-test-sub-prototypes.pl +#-------------------------------------------------------------------------- +# compiled all relevant subroutine prototype test cases +# +#-------------------------------------------------------------------------- +# Kein-Hong Man <keinhong@gmail.com> Public Domain +#-------------------------------------------------------------------------- +# 20151227 initial document +#-------------------------------------------------------------------------- +{0} +{2}#-------------------------------------------------------------------------- +# test cases for sub syntax scanner +#-------------------------------------------------------------------------- +# sub syntax: simple and with added module notation +#-------------------------------------------------------------------------- +{0} {5}sub{0} {11}fish{40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} -{5}sub{0} {11}fish{10}::{11}chips{40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# module syntax{0} -{5}sub{0} {11}fish{10}::{11}chips{10}::{11}sauce{40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# multiple module syntax{0} - -{5}sub{0} {11}fish{0} {10}::{0} {11}chips{0} {10}::{0} {11}sauce{0} {40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# added whitespace{0} - -{5}sub{0} {11}fish{0} {10}::{0} {2}# embedded comment{0} -{11}chips{0} {2}# embedded comment{0} - {10}::{0} {11}sauce{0} {40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} - -{5}sub{0} {11}fish{0} {10}::{0} {10}({12}$){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# incomplete or bad syntax examples{0} +{5}sub{0} {11}fish{10}::{11}chips{40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# module syntax +{5}sub{0} {11}fish{10}::{11}chips{10}::{11}sauce{40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# multiple module syntax +{0} +{5}sub{0} {11}fish{0} {10}::{0} {11}chips{0} {10}::{0} {11}sauce{0} {40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# added whitespace +{0} +{5}sub{0} {11}fish{0} {10}::{0} {2}# embedded comment +{11}chips{0} {2}# embedded comment +{0} {10}::{0} {11}sauce{0} {40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} + +{5}sub{0} {11}fish{0} {10}::{0} {10}({12}$){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# incomplete or bad syntax examples {5}sub{0} {11}fish{0} {10}::{0} {4}123{0} {10}({12}$){0} {10}{{0} {4}123{10};{0} {10}}{0} {5}sub{0} {11}fish{0} {10}::{0} {11}chips{0} {4}123{0} {10}({12}$){0} {10}{{0} {4}123{10};{0} {10}}{0} {5}sub{0} {4}123{0} {10}({12}$){0} {10}{{0} {4}123{10};{0} {10}}{0} -{2}#--------------------------------------------------------------------------{0} -{2}# sub syntax: prototype attributes{0} -{2}#--------------------------------------------------------------------------{0} - +{2}#-------------------------------------------------------------------------- +# sub syntax: prototype attributes +#-------------------------------------------------------------------------- +{0} {5}sub{0} {11}fish{10}:{5}prototype{40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} -{5}sub{0} {11}fish{0} {10}:{0} {5}prototype{0} {40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# added whitespace{0} - -{5}sub{0} {11}fish{10}:{11}salted{10}({12}$){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# wrong attribute example (must use 'prototype'){0} -{5}sub{0} {11}fish{0} {10}:{0} {4}123{10}({12}$){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# illegal attribute{0} -{5}sub{0} {11}fish{10}:{5}prototype{10}:{11}salted{10}({12}$){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# wrong 'prototype' position{0} -{5}sub{0} {11}fish{10}:{11}salted{0} {11}salt{10}:{5}prototype{10}({12}$){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# wrong attribute syntax{0} - -{5}sub{0} {11}fish{10}:{11}const{10}:{5}prototype{40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# extra attributes{0} +{5}sub{0} {11}fish{0} {10}:{0} {5}prototype{0} {40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# added whitespace +{0} +{5}sub{0} {11}fish{10}:{11}salted{10}({12}$){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# wrong attribute example (must use 'prototype') +{5}sub{0} {11}fish{0} {10}:{0} {4}123{10}({12}$){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# illegal attribute +{5}sub{0} {11}fish{10}:{5}prototype{10}:{11}salted{10}({12}$){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# wrong 'prototype' position +{5}sub{0} {11}fish{10}:{11}salted{0} {11}salt{10}:{5}prototype{10}({12}$){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# wrong attribute syntax +{0} +{5}sub{0} {11}fish{10}:{11}const{10}:{5}prototype{40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# extra attributes {5}sub{0} {11}fish{10}:{11}const{10}:{11}lvalue{10}:{5}prototype{40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} -{5}sub{0} {11}fish{10}:{11}const{10}:{5}prototype{40}($){10}:{11}lvalue{10}{{0} {4}123{10};{0} {10}}{0} {2}# might be legal too{0} -{5}sub{0} {11}fish{0} {10}:{11}const{0} {10}:{5}prototype{40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# extra whitespace{0} - -{5}sub{0} {11}fish{0} {10}:{11}const{0} {2}# embedded comment: a constant sub{0} -{10}:{5}prototype{0} {2}# embedded comment{0} +{5}sub{0} {11}fish{10}:{11}const{10}:{5}prototype{40}($){10}:{11}lvalue{10}{{0} {4}123{10};{0} {10}}{0} {2}# might be legal too +{5}sub{0} {11}fish{0} {10}:{11}const{0} {10}:{5}prototype{40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# extra whitespace +{0} +{5}sub{0} {11}fish{0} {10}:{11}const{0} {2}# embedded comment: a constant sub +{10}:{5}prototype{0} {2}# embedded comment {40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} -{2}#--------------------------------------------------------------------------{0} -{2}# sub syntax: mixed{0} -{2}#--------------------------------------------------------------------------{0} - +{2}#-------------------------------------------------------------------------- +# sub syntax: mixed +#-------------------------------------------------------------------------- +{0} {5}sub{0} {11}fish{10}::{11}chips{10}:{5}prototype{40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} {5}sub{0} {11}fish{10}::{11}chips{10}::{11}sauce{10}:{5}prototype{40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} -{5}sub{0} {11}fish{0} {10}::{11}chips{0} {10}::{11}sauce{0} {10}:{5}prototype{40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# +whitespace{0} - +{5}sub{0} {11}fish{0} {10}::{11}chips{0} {10}::{11}sauce{0} {10}:{5}prototype{40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# +whitespace +{0} {5}sub{0} {11}fish{10}::{11}chips{10}::{11}sauce{10}:{11}const{10}:{5}prototype{40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} -{5}sub{0} {11}fish{10}::{11}chips{10}::{11}sauce{0} {10}:{11}const{0} {10}:{5}prototype{40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# +whitespace{0} - -{5}sub{0} {11}fish{0} {2}# embedded comment{0} -{10}::{11}chips{0} {10}::{11}sauce{0} {2}# embedded comment{0} - {10}:{0} {11}const{0} {2}# embedded comment{0} - {10}:{0} {5}prototype{0} {40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} - -{2}# wrong syntax examples, parentheses must follow ':prototype'{0} +{5}sub{0} {11}fish{10}::{11}chips{10}::{11}sauce{0} {10}:{11}const{0} {10}:{5}prototype{40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# +whitespace +{0} +{5}sub{0} {11}fish{0} {2}# embedded comment +{10}::{11}chips{0} {10}::{11}sauce{0} {2}# embedded comment +{0} {10}:{0} {11}const{0} {2}# embedded comment +{0} {10}:{0} {5}prototype{0} {40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} + +{2}# wrong syntax examples, parentheses must follow ':prototype' {5}sub{0} {11}fish{0} {10}:{5}prototype{0} {10}:{11}const{0} {10}({12}$){0} {10}{{0} {4}123{10};}{0} {5}sub{0} {11}fish{0} {10}:{5}prototype{0} {10}::{11}chips{0} {10}({12}$){0} {10}{{0} {4}123{10};}{0} -{2}#--------------------------------------------------------------------------{0} -{2}# perl-test-5200delta.pl{0} -{2}#--------------------------------------------------------------------------{0} -{2}# More consistent prototype parsing{0} -{2}#--------------------------------------------------------------------------{0} -{2}# - whitespace now allowed, lexer now allows spaces or tabs{0} - +{2}#-------------------------------------------------------------------------- +# perl-test-5200delta.pl +#-------------------------------------------------------------------------- +# More consistent prototype parsing +#-------------------------------------------------------------------------- +# - whitespace now allowed, lexer now allows spaces or tabs +{0} {5}sub{0} {11}foo{0} {40}( $ $ ){0} {10}{}{0} -{5}sub{0} {11}foo{0} {40}( ){0} {10}{}{0} {2}# spaces/tabs empty{0} +{5}sub{0} {11}foo{0} {40}( ){0} {10}{}{0} {2}# spaces/tabs empty {5}sub{0} {11}foo{0} {40}( * ){0} {10}{}{0} {5}sub{0} {11}foo{0} {40}(@ ){0} {10}{}{0} {5}sub{0} {11}foo{0} {40}( %){0} {10}{}{0} -{2}# untested, should probably be \[ but scanner does not check this for now{0} +{2}# untested, should probably be \[ but scanner does not check this for now {5}sub{0} {11}foo{0} {40}( \ [ $ @ % & * ] ){0} {10}{}{0} -{2}#--------------------------------------------------------------------------{0} -{2}# perl-test-5140delta.pl{0} -{2}#--------------------------------------------------------------------------{0} -{2}# new + prototype character, acts like (\[@%]){0} -{2}#--------------------------------------------------------------------------{0} - -{2}# these samples work as before{0} -{5}sub{0} {11}mylink{0} {40}($$){0} {2}# mylink $old, $new{0} -{5}sub{0} {11}myvec{0} {40}($$$){0} {2}# myvec $var, $offset, 1{0} -{5}sub{0} {11}myindex{0} {40}($$;$){0} {2}# myindex &getstring, "substr"{0} -{5}sub{0} {11}mysyswrite{0} {40}($$$;$){0} {2}# mysyswrite $buf, 0, length($buf) - $off, $off{0} -{5}sub{0} {11}myreverse{0} {40}(@){0} {2}# myreverse $a, $b, $c{0} -{5}sub{0} {11}myjoin{0} {40}($@){0} {2}# myjoin ":", $a, $b, $c{0} -{5}sub{0} {11}myopen{0} {40}(*;$){0} {2}# myopen HANDLE, $name{0} -{5}sub{0} {11}mypipe{0} {40}(**){0} {2}# mypipe READHANDLE, WRITEHANDLE{0} -{5}sub{0} {11}mygrep{0} {40}(&@){0} {2}# mygrep { /foo/ } $a, $b, $c{0} -{5}sub{0} {11}myrand{0} {40}(;$){0} {2}# myrand 42{0} -{5}sub{0} {11}mytime{0} {40}(){0} {2}# mytime{0} - -{2}# backslash group notation to specify more than one allowed argument type{0} +{2}#-------------------------------------------------------------------------- +# perl-test-5140delta.pl +#-------------------------------------------------------------------------- +# new + prototype character, acts like (\[@%]) +#-------------------------------------------------------------------------- +{0} +{2}# these samples work as before +{5}sub{0} {11}mylink{0} {40}($$){0} {2}# mylink $old, $new +{5}sub{0} {11}myvec{0} {40}($$$){0} {2}# myvec $var, $offset, 1 +{5}sub{0} {11}myindex{0} {40}($$;$){0} {2}# myindex &getstring, "substr" +{5}sub{0} {11}mysyswrite{0} {40}($$$;$){0} {2}# mysyswrite $buf, 0, length($buf) - $off, $off +{5}sub{0} {11}myreverse{0} {40}(@){0} {2}# myreverse $a, $b, $c +{5}sub{0} {11}myjoin{0} {40}($@){0} {2}# myjoin ":", $a, $b, $c +{5}sub{0} {11}myopen{0} {40}(*;$){0} {2}# myopen HANDLE, $name +{5}sub{0} {11}mypipe{0} {40}(**){0} {2}# mypipe READHANDLE, WRITEHANDLE +{5}sub{0} {11}mygrep{0} {40}(&@){0} {2}# mygrep { /foo/ } $a, $b, $c +{5}sub{0} {11}myrand{0} {40}(;$){0} {2}# myrand 42 +{5}sub{0} {11}mytime{0} {40}(){0} {2}# mytime +{0} +{2}# backslash group notation to specify more than one allowed argument type {5}sub{0} {11}myref{0} {40}(\[$@%&*]){0} {10}{}{0} -{5}sub{0} {11}mysub{0} {40}(_){0} {2}# underscore can be optionally used FIXED 20151211{0} - -{2}# these uses the new '+' prototype character{0} -{5}sub{0} {11}mypop{0} {40}(+){0} {2}# mypop @array{0} -{5}sub{0} {11}mysplice{0} {40}(+$$@){0} {2}# mysplice @array, 0, 2, @pushme{0} -{5}sub{0} {11}mykeys{0} {40}(+){0} {2}# mykeys %{$hashref}{0} - -{2}#--------------------------------------------------------------------------{0} -{2}# perl-test-5200delta.pl{0} -{2}#--------------------------------------------------------------------------{0} -{2}# Experimental Subroutine signatures (mostly works){0} -{2}#--------------------------------------------------------------------------{0} -{2}# INCLUDED FOR COMPLETENESS ONLY{0} -{2}# IMPORTANT NOTE the subroutine prototypes lexing implementation has{0} -{2}# no effect on subroutine signature syntax highlighting{0} - -{2}# subroutine signatures mostly looks fine except for the @ and % slurpy{0} -{2}# notation which are highlighted as operators (all other parameters are{0} -{2}# highlighted as vars of some sort), a minor aesthetic issue{0} - +{5}sub{0} {11}mysub{0} {40}(_){0} {2}# underscore can be optionally used FIXED 20151211 +{0} +{2}# these uses the new '+' prototype character +{5}sub{0} {11}mypop{0} {40}(+){0} {2}# mypop @array +{5}sub{0} {11}mysplice{0} {40}(+$$@){0} {2}# mysplice @array, 0, 2, @pushme +{5}sub{0} {11}mykeys{0} {40}(+){0} {2}# mykeys %{$hashref} +{0} +{2}#-------------------------------------------------------------------------- +# perl-test-5200delta.pl +#-------------------------------------------------------------------------- +# Experimental Subroutine signatures (mostly works) +#-------------------------------------------------------------------------- +# INCLUDED FOR COMPLETENESS ONLY +# IMPORTANT NOTE the subroutine prototypes lexing implementation has +# no effect on subroutine signature syntax highlighting +{0} +{2}# subroutine signatures mostly looks fine except for the @ and % slurpy +# notation which are highlighted as operators (all other parameters are +# highlighted as vars of some sort), a minor aesthetic issue +{0} {5}use{0} {11}feature{0} {7}'signatures'{10};{0} -{5}sub{0} {11}foo{0} {10}({12}$left{10},{0} {12}$right{10}){0} {10}{{0} {2}# mandatory positional parameters{0} - {5}return{0} {12}$left{0} {10}+{0} {12}$right{10};{0} +{5}sub{0} {11}foo{0} {10}({12}$left{10},{0} {12}$right{10}){0} {10}{{0} {2}# mandatory positional parameters +{0} {5}return{0} {12}$left{0} {10}+{0} {12}$right{10};{0} {10}}{0} -{5}sub{0} {11}foo{0} {10}({12}$first{10},{0} {12}$,{0} {12}$third{10}){0} {10}{{0} {2}# ignore second argument{0} - {5}return{0} {6}"first={43}$first{6}, third={43}$third{6}"{10};{0} +{5}sub{0} {11}foo{0} {10}({12}$first{10},{0} {12}$,{0} {12}$third{10}){0} {10}{{0} {2}# ignore second argument +{0} {5}return{0} {6}"first={43}$first{6}, third={43}$third{6}"{10};{0} {10}}{0} -{5}sub{0} {11}foo{0} {10}({12}$left{10},{0} {12}$right{0} {10}={0} {4}0{10}){0} {10}{{0} {2}# optional parameter with default value{0} - {5}return{0} {12}$left{0} {10}+{0} {12}$right{10};{0} +{5}sub{0} {11}foo{0} {10}({12}$left{10},{0} {12}$right{0} {10}={0} {4}0{10}){0} {10}{{0} {2}# optional parameter with default value +{0} {5}return{0} {12}$left{0} {10}+{0} {12}$right{10};{0} {10}}{0} -{5}my{0} {12}$auto_id{0} {10}={0} {4}0{10};{0} {2}# default value expression, evaluated if default used only{0} +{5}my{0} {12}$auto_id{0} {10}={0} {4}0{10};{0} {2}# default value expression, evaluated if default used only {5}sub{0} {11}foo{0} {10}({12}$thing{10},{0} {12}$id{0} {10}={0} {12}$auto_id{10}++){0} {10}{{0} {5}print{0} {6}"{43}$thing{6} has ID {43}$id{6}"{10};{0} {10}}{0} -{5}sub{0} {11}foo{0} {10}({12}$first_name{10},{0} {12}$surname{10},{0} {12}$nickname{0} {10}={0} {12}$first_name{10}){0} {10}{{0} {2}# 3rd parm may depend on 1st parm{0} - {5}print{0} {6}"{43}$first_name{6} {43}$surname{6} is known as \"{43}$nickname{6}\""{10};{0} +{5}sub{0} {11}foo{0} {10}({12}$first_name{10},{0} {12}$surname{10},{0} {12}$nickname{0} {10}={0} {12}$first_name{10}){0} {10}{{0} {2}# 3rd parm may depend on 1st parm +{0} {5}print{0} {6}"{43}$first_name{6} {43}$surname{6} is known as \"{43}$nickname{6}\""{10};{0} {10}}{0} -{5}sub{0} {11}foo{0} {10}({12}$thing{10},{0} {12}${0} {10}={0} {4}1{10}){0} {10}{{0} {2}# nameless default parameter{0} - {5}print{0} {12}$thing{10};{0} +{5}sub{0} {11}foo{0} {10}({12}$thing{10},{0} {12}${0} {10}={0} {4}1{10}){0} {10}{{0} {2}# nameless default parameter +{0} {5}print{0} {12}$thing{10};{0} {10}}{0} -{5}sub{0} {11}foo{0} {10}({12}$thing{10},{0} {12}$={10}){0} {10}{{0} {2}# (this does something, I'm not sure what...){0} - {5}print{0} {12}$thing{10};{0} +{5}sub{0} {11}foo{0} {10}({12}$thing{10},{0} {12}$={10}){0} {10}{{0} {2}# (this does something, I'm not sure what...) +{0} {5}print{0} {12}$thing{10};{0} {10}}{0} -{5}sub{0} {11}foo{0} {10}({12}$filter{10},{0} {13}@inputs{10}){0} {10}{{0} {2}# additional arguments (slurpy parameter){0} - {5}print{0} {12}$filter{10}->({12}$_{10}){0} {5}foreach{0} {13}@inputs{10};{0} +{5}sub{0} {11}foo{0} {10}({12}$filter{10},{0} {13}@inputs{10}){0} {10}{{0} {2}# additional arguments (slurpy parameter) +{0} {5}print{0} {12}$filter{10}->({12}$_{10}){0} {5}foreach{0} {13}@inputs{10};{0} {10}}{0} -{5}sub{0} {11}foo{0} {10}({12}$thing{10},{0} {10}@){0} {10}{{0} {2}# nameless slurpy parameter FAILS for now{0} - {5}print{0} {12}$thing{10};{0} +{5}sub{0} {11}foo{0} {10}({12}$thing{10},{0} {10}@){0} {10}{{0} {2}# nameless slurpy parameter FAILS for now +{0} {5}print{0} {12}$thing{10};{0} {10}}{0} -{5}sub{0} {11}foo{0} {10}({12}$filter{10},{0} {14}%inputs{10}){0} {10}{{0} {2}# slurpy parameter, hash type{0} - {5}print{0} {12}$filter{10}->({12}$_{10},{0} {12}$inputs{10}{{12}$_{10}}){0} {5}foreach{0} {5}sort{0} {5}keys{0} {14}%inputs{10};{0} +{5}sub{0} {11}foo{0} {10}({12}$filter{10},{0} {14}%inputs{10}){0} {10}{{0} {2}# slurpy parameter, hash type +{0} {5}print{0} {12}$filter{10}->({12}$_{10},{0} {12}$inputs{10}{{12}$_{10}}){0} {5}foreach{0} {5}sort{0} {5}keys{0} {14}%inputs{10};{0} {10}}{0} -{5}sub{0} {11}foo{0} {10}({12}$thing{10},{0} {10}%){0} {10}{{0} {2}# nameless slurpy parm, hash type FAILS for now{0} - {5}print{0} {12}$thing{10};{0} +{5}sub{0} {11}foo{0} {10}({12}$thing{10},{0} {10}%){0} {10}{{0} {2}# nameless slurpy parm, hash type FAILS for now +{0} {5}print{0} {12}$thing{10};{0} {10}}{0} -{5}sub{0} {11}foo{0} {40}(){0} {10}{{0} {2}# empty signature no arguments (styled as prototype){0} - {5}return{0} {4}123{10};{0} +{5}sub{0} {11}foo{0} {40}(){0} {10}{{0} {2}# empty signature no arguments (styled as prototype) +{0} {5}return{0} {4}123{10};{0} {10}}{0} -{2}#--------------------------------------------------------------------------{0} -{2}# perl-test-5200delta.pl{0} -{2}#--------------------------------------------------------------------------{0} -{2}# subs now take a prototype attribute{0} -{2}#--------------------------------------------------------------------------{0} - +{2}#-------------------------------------------------------------------------- +# perl-test-5200delta.pl +#-------------------------------------------------------------------------- +# subs now take a prototype attribute +#-------------------------------------------------------------------------- +{0} {5}sub{0} {11}foo{0} {10}:{5}prototype{40}($){0} {10}{{0} {12}$_{10}[{4}0{10}]{0} {10}}{0} {5}sub{0} {11}foo{0} {10}:{5}prototype{40}($$){0} {10}({12}$left{10},{0} {12}$right{10}){0} {10}{{0} {5}return{0} {12}$left{0} {10}+{0} {12}$right{10};{0} {10}}{0} -{5}sub{0} {11}foo{0} {10}:{0} {5}prototype{40}($$){10}{}{0} {2}# whitespace allowed{0} - -{2}# additional samples from perl-test-cases.pl with ':prototype' added:{0} +{5}sub{0} {11}foo{0} {10}:{0} {5}prototype{40}($$){10}{}{0} {2}# whitespace allowed +{0} +{2}# additional samples from perl-test-cases.pl with ':prototype' added: {5}sub{0} {11}mylink{0} {10}:{5}prototype{40}($$){0} {10}{}{0} {5}sub{0} {11}myvec{0} {10}:{5}prototype{40}($$$){0} {10}{}{0} {5}sub{0} {11}myindex{0} {10}:{5}prototype{40}($$;$){0} {10}{}{0} {5}sub{0} {11}mysyswrite{0} {10}:{5}prototype{40}($$$;$){0} {10}{}{0} {5}sub{0} {11}myreverse{0} {10}:{5}prototype{40}(@){0} {10}{}{0} {5}sub{0} {11}myjoin{0} {10}:{5}prototype{40}($@){0} {10}{}{0} @@ -192,33 +192,33 @@ {5}sub{0} {11}mykeys{0} {10}:{5}prototype{40}(\%){0} {10}{}{0} {5}sub{0} {11}myopen{0} {10}:{5}prototype{40}(*;$){0} {10}{}{0} {5}sub{0} {11}mypipe{0} {10}:{5}prototype{40}(**){0} {10}{}{0} {5}sub{0} {11}mygrep{0} {10}:{5}prototype{40}(&@){0} {10}{}{0} {5}sub{0} {11}myrand{0} {10}:{5}prototype{40}($){0} {10}{}{0} {5}sub{0} {11}mytime{0} {10}:{5}prototype{40}(){0} {10}{}{0} -{2}# backslash group notation to specify more than one allowed argument type{0} +{2}# backslash group notation to specify more than one allowed argument type {5}sub{0} {11}myref{0} {10}:{5}prototype{40}(\[$@%&*]){0} {10}{}{0} -{2}# additional attributes may complicate scanning for prototype syntax,{0} -{2}# for example (from https://metacpan.org/pod/perlsub):{0} -{2}# Lvalue subroutines{0} - +{2}# additional attributes may complicate scanning for prototype syntax, +# for example (from https://metacpan.org/pod/perlsub): +# Lvalue subroutines +{0} {5}my{0} {12}$val{10};{0} {5}sub{0} {11}canmod{0} {10}:{0} {11}lvalue{0} {10}{{0} - {12}$val{10};{0} {2}# or: return $val;{0} + {12}$val{10};{0} {2}# or: return $val; {10}}{0} -{11}canmod{10}(){0} {10}={0} {4}5{10};{0} {2}# assigns to $val{0} - -{2}#--------------------------------------------------------------------------{0} -{2}# perl-test-5220delta.pl{0} -{2}#--------------------------------------------------------------------------{0} -{2}# New :const subroutine attribute{0} -{2}#--------------------------------------------------------------------------{0} - +{11}canmod{10}(){0} {10}={0} {4}5{10};{0} {2}# assigns to $val +{0} +{2}#-------------------------------------------------------------------------- +# perl-test-5220delta.pl +#-------------------------------------------------------------------------- +# New :const subroutine attribute +#-------------------------------------------------------------------------- +{0} {5}my{0} {12}$x{0} {10}={0} {4}54321{10};{0} {15}*INLINED{0} {10}={0} {5}sub{0} {10}:{0} {11}const{0} {10}{{0} {12}$x{0} {10}};{0} {12}$x{10}++;{0} -{2}# more examples of attributes{0} -{2}# (not 5.22 stuff, but some general examples for study, useful for{0} -{2}# handling subroutine signature and subroutine prototype highlighting){0} - +{2}# more examples of attributes +# (not 5.22 stuff, but some general examples for study, useful for +# handling subroutine signature and subroutine prototype highlighting) +{0} {5}sub{0} {11}foo{0} {10}:{0} {11}lvalue{0} {10};{0} {5}package{0} {11}X{10};{0} @@ -231,9 +231,9 @@ {5}package{0} {11}Z{10};{0} {5}sub{0} {11}Y{10}::{11}bar{0} {10}:{0} {11}lvalue{0} {10};{0} -{2}# built-in attributes for subroutines:{0} +{2}# built-in attributes for subroutines: {11}lvalue{0} {11}method{0} {5}prototype{10}(..){0} {11}locked{0} {11}const{0} -{2}#--------------------------------------------------------------------------{0} -{2}# end of test file{0} -{2}#--------------------------------------------------------------------------{0} +{2}#-------------------------------------------------------------------------- +# end of test file +#-------------------------------------------------------------------------- diff --git a/test/examples/perl-test-5220delta.pl.styled b/test/examples/perl-test-5220delta.pl.styled index 3754c8929..4a763a47a 100644 --- a/test/examples/perl-test-5220delta.pl.styled +++ b/test/examples/perl-test-5220delta.pl.styled @@ -1,82 +1,82 @@ -{2}# -*- coding: utf-8 -*-{0} -{2}#--------------------------------------------------------------------------{0} -{2}# perl-test-5220delta.pl{0} -{2}#--------------------------------------------------------------------------{0} -{2}# REF: https://metacpan.org/pod/distribution/perl/pod/perldelta.pod{0} -{2}# maybe future ref: https://metacpan.org/pod/distribution/perl/pod/perl5220delta.pod{0} -{2}# also: http://perltricks.com/article/165/2015/4/10/A-preview-of-Perl-5-22{0} -{2}#{0} -{2}#--------------------------------------------------------------------------{0} -{2}# Kein-Hong Man <keinhong@gmail.com> Public Domain 20151217{0} -{2}#--------------------------------------------------------------------------{0} -{2}# 20151217 initial document{0} -{2}# 20151218 updated tests and comments{0} -{2}#--------------------------------------------------------------------------{0} - -{5}use{0} {6}v5.22{10};{0} {2}# may be needed{0} - -{2}#--------------------------------------------------------------------------{0} -{2}# New bitwise operators{0} -{2}#--------------------------------------------------------------------------{0} - -{5}use{0} {11}feature{0} {7}'bitwise'{0} {2}# enable feature, warning enabled{0} -{5}use{0} {11}experimental{0} {6}"bitwise"{10};{0} {2}# enable feature, warning disabled{0} - -{2}# numerical operands{0} +{2}# -*- coding: utf-8 -*- +#-------------------------------------------------------------------------- +# perl-test-5220delta.pl +#-------------------------------------------------------------------------- +# REF: https://metacpan.org/pod/distribution/perl/pod/perldelta.pod +# maybe future ref: https://metacpan.org/pod/distribution/perl/pod/perl5220delta.pod +# also: http://perltricks.com/article/165/2015/4/10/A-preview-of-Perl-5-22 +# +#-------------------------------------------------------------------------- +# Kein-Hong Man <keinhong@gmail.com> Public Domain 20151217 +#-------------------------------------------------------------------------- +# 20151217 initial document +# 20151218 updated tests and comments +#-------------------------------------------------------------------------- +{0} +{5}use{0} {6}v5.22{10};{0} {2}# may be needed +{0} +{2}#-------------------------------------------------------------------------- +# New bitwise operators +#-------------------------------------------------------------------------- +{0} +{5}use{0} {11}feature{0} {7}'bitwise'{0} {2}# enable feature, warning enabled +{5}use{0} {11}experimental{0} {6}"bitwise"{10};{0} {2}# enable feature, warning disabled +{0} +{2}# numerical operands {4}10{10}&{4}20{0} {4}10{10}|{4}20{0} {4}10{10}^{4}20{0} {10}~{4}10{0} {12}$a{10}&{6}"8"{0} {12}$a{10}|{6}"8"{0} {12}$a{10}^{6}"8"{0} {10}~{12}$a{0} {10}~{6}"8"{0} -{2}# string operands{0} +{2}# string operands {7}'0'{10}&.{6}"8"{0} {7}'0'{10}|.{6}"8"{0} {7}'0'{10}^.{6}"8"{0} {10}~.{7}'0'{0} {10}~.{6}"8"{0} -{2}# the following is AMBIGUOUS, perl sees 10 and not .10 only when bitwise feature is enabled{0} -{2}# so it's feature-setting-dependent, no plans to change current behaviour{0} - {12}$a{10}&{4}.10{0} {12}$a{10}|{4}.10{0} {12}$a{10}^{4}.10{0} {10}~.{12}$a{0} {10}~{4}.10{0} +{2}# the following is AMBIGUOUS, perl sees 10 and not .10 only when bitwise feature is enabled +# so it's feature-setting-dependent, no plans to change current behaviour +{0} {12}$a{10}&{4}.10{0} {12}$a{10}|{4}.10{0} {12}$a{10}^{4}.10{0} {10}~.{12}$a{0} {10}~{4}.10{0} -{2}# assignment variants{0} +{2}# assignment variants {12}$a{10}&={4}10{10};{0} {12}$a{10}|={4}10{10};{0} {12}$a{10}^={4}10{10};{0} {12}$b{10}&.={7}'20'{10};{0} {12}$b{10}|.={7}'20'{10};{0} {12}$b{10}^.={7}'20'{10};{0} {12}$c{10}&={6}"30"{10};{0} {12}$c{10}|={6}"30"{10};{0} {12}$c{10}^={6}"30"{10};{0} {12}$d{10}&.={12}$e{10};{0} {12}$d{10}|.={12}$e{10};{0} {12}$d{10}^.={12}$e{10};{0} -{2}#--------------------------------------------------------------------------{0} -{2}# New double-diamond operator{0} -{2}#--------------------------------------------------------------------------{0} -{2}# <<>> is like <> but each element of @ARGV will be treated as an actual file name{0} - -{2}# example snippet from brian d foy's blog post{0} -{5}while{10}({0} {10}<<>>{0} {10}){0} {10}{{0} {2}# new, safe line input operator{0} - {10}...;{0} +{2}#-------------------------------------------------------------------------- +# New double-diamond operator +#-------------------------------------------------------------------------- +# <<>> is like <> but each element of @ARGV will be treated as an actual file name +{0} +{2}# example snippet from brian d foy's blog post +{5}while{10}({0} {10}<<>>{0} {10}){0} {10}{{0} {2}# new, safe line input operator +{0} {10}...;{0} {10}}{0} -{2}#--------------------------------------------------------------------------{0} -{2}# New \b boundaries in regular expressions{0} -{2}#--------------------------------------------------------------------------{0} - +{2}#-------------------------------------------------------------------------- +# New \b boundaries in regular expressions +#-------------------------------------------------------------------------- +{0} {29}qr/\b{gcb}/{0} {29}qr/\b{wb}/{0} {29}qr/\b{sb}/{0} -{2}#--------------------------------------------------------------------------{0} -{2}# Non-Capturing Regular Expression Flag{0} -{2}#--------------------------------------------------------------------------{0} -{2}# disables capturing and filling in $1, $2, etc{0} - -{6}"hello"{0} {10}=~{0} {17}/(hi|hello)/n{10};{0} {2}# $1 is not set{0} - -{2}#--------------------------------------------------------------------------{0} -{2}# Aliasing via reference{0} -{2}#--------------------------------------------------------------------------{0} -{2}# Variables and subroutines can now be aliased by assigning to a reference{0} - +{2}#-------------------------------------------------------------------------- +# Non-Capturing Regular Expression Flag +#-------------------------------------------------------------------------- +# disables capturing and filling in $1, $2, etc +{0} +{6}"hello"{0} {10}=~{0} {17}/(hi|hello)/n{10};{0} {2}# $1 is not set +{0} +{2}#-------------------------------------------------------------------------- +# Aliasing via reference +#-------------------------------------------------------------------------- +# Variables and subroutines can now be aliased by assigning to a reference +{0} {10}\{12}$c{0} {10}={0} {10}\{12}$d{10};{0} {10}\&{11}x{0} {10}={0} {10}\&{11}y{10};{0} -{2}# Aliasing can also be applied to foreach iterator variables{0} - +{2}# Aliasing can also be applied to foreach iterator variables +{0} {5}foreach{0} {10}\{14}%hash{0} {10}({13}@array_of_hash_refs{10}){0} {10}{{0} {10}...{0} {10}}{0} -{2}# example snippet from brian d foy's blog post{0} - +{2}# example snippet from brian d foy's blog post +{0} {5}use{0} {11}feature{0} {30}qw(refaliasing){10};{0} {10}\{14}%other_hash{0} {10}={0} {10}\{14}%hash{10};{0} @@ -84,24 +84,24 @@ {5}use{0} {6}v5.22{10};{0} {5}use{0} {11}feature{0} {30}qw(refaliasing){10};{0} -{5}foreach{0} {10}\{5}my{0} {14}%hash{0} {10}({0} {13}@array_of_hashes{0} {10}){0} {10}{{0} {2}# named hash control variable{0} - {5}foreach{0} {5}my{0} {12}$key{0} {10}({0} {5}keys{0} {14}%hash{0} {10}){0} {10}{{0} {2}# named hash now!{0} - {10}...;{0} +{5}foreach{0} {10}\{5}my{0} {14}%hash{0} {10}({0} {13}@array_of_hashes{0} {10}){0} {10}{{0} {2}# named hash control variable +{0} {5}foreach{0} {5}my{0} {12}$key{0} {10}({0} {5}keys{0} {14}%hash{0} {10}){0} {10}{{0} {2}# named hash now! +{0} {10}...;{0} {10}}{0} {10}}{0} -{2}#--------------------------------------------------------------------------{0} -{2}# New :const subroutine attribute{0} -{2}#--------------------------------------------------------------------------{0} - +{2}#-------------------------------------------------------------------------- +# New :const subroutine attribute +#-------------------------------------------------------------------------- +{0} {5}my{0} {12}$x{0} {10}={0} {4}54321{10};{0} {15}*INLINED{0} {10}={0} {5}sub{0} {10}:{0} {11}const{0} {10}{{0} {12}$x{0} {10}};{0} {12}$x{10}++;{0} -{2}# more examples of attributes{0} -{2}# (not 5.22 stuff, but some general examples for study, useful for{0} -{2}# handling subroutine signature and subroutine prototype highlighting){0} - +{2}# more examples of attributes +# (not 5.22 stuff, but some general examples for study, useful for +# handling subroutine signature and subroutine prototype highlighting) +{0} {5}sub{0} {11}foo{0} {10}:{0} {11}lvalue{0} {10};{0} {5}package{0} {11}X{10};{0} @@ -114,30 +114,30 @@ {5}package{0} {11}Z{10};{0} {5}sub{0} {11}Y{10}::{11}bar{0} {10}:{0} {11}lvalue{0} {10};{0} -{2}# built-in attributes for subroutines:{0} +{2}# built-in attributes for subroutines: {11}lvalue{0} {11}method{0} {5}prototype{10}(..){0} {11}locked{0} {11}const{0} -{2}#--------------------------------------------------------------------------{0} -{2}# Repetition in list assignment{0} -{2}#--------------------------------------------------------------------------{0} - -{2}# example snippet from brian d foy's blog post{0} +{2}#-------------------------------------------------------------------------- +# Repetition in list assignment +#-------------------------------------------------------------------------- +{0} +{2}# example snippet from brian d foy's blog post {5}use{0} {6}v5.22{10};{0} {5}my{10}({5}undef{10},{0} {12}$card_num{10},{0} {10}({5}undef{10})x{4}3{10},{0} {12}$count{10}){0} {10}={0} {5}split{0} {17}/:/{10};{0} {10}({5}undef{10},{5}undef{10},{12}$foo{10}){0} {10}={0} {11}that_function{10}(){0} -{2}# is equivalent to {0} +{2}# is equivalent to {10}(({5}undef{10})x{4}2{10},{0} {12}$foo{10}){0} {10}={0} {11}that_function{10}(){0} -{2}#--------------------------------------------------------------------------{0} -{2}# Floating point parsing has been improved{0} -{2}#--------------------------------------------------------------------------{0} -{2}# Hexadecimal floating point literals{0} - -{2}# some hex floats from a program by Rick Regan{0} -{2}# appropriated and extended from Lua 5.2.x test cases{0} -{2}# tested on perl 5.22/cygwin{0} - +{2}#-------------------------------------------------------------------------- +# Floating point parsing has been improved +#-------------------------------------------------------------------------- +# Hexadecimal floating point literals +{0} +{2}# some hex floats from a program by Rick Regan +# appropriated and extended from Lua 5.2.x test cases +# tested on perl 5.22/cygwin +{0} {4}0x1p-1074{10};{0} {4}0x3.3333333333334p-5{10};{0} {4}0xcc.ccccccccccdp-11{10};{0} @@ -149,30 +149,30 @@ {4}0X1.921FB4D12D84AP+1{10};{0} {4}0x1.999999999999ap-4{10};{0} -{2}# additional test cases for characterization{0} -{4}0x1p-1074{10}.{0} {2}# dot is a string operator{0} -{4}0x.ABCDEFp10{0} {2}# legal, dot immediately after 0x{0} -{4}0x{10}.{11}p10{0} {2}# perl allows 0x as a zero, then concat with p10 bareword{0} -{4}0x{10}.{11}p{0} {4}0x0{10}.{11}p{0} {2}# dot then bareword{0} -{4}0x_0_.A_BC___DEF_p1_0{0} {2}# legal hex float, underscores are mostly allowed{0} -{4}0x0{10}.{11}_ABCDEFp10{0} {2}# _ABCDEFp10 is a bareword, no underscore allowed after dot{0} - -{2}# illegal, but does not use error highlighting{0} -{4}0x0p1{11}ABC{0} {2}# illegal, highlighted as 0x0p1 abut with bareword ABC {0} - -{2}# allowed to FAIL for now{0} -{4}0x0.ABCDEFp_10{0} {2}# ABCDEFp_10 is a bareword, '_10' exponent not allowed{0} -{4}0xp{0} {4}0xp1{0} {4}0x0.0p{0} {2}# syntax errors{0} -{4}0x41.65{10}.{4}65{0} {2}# hex dot number, but lexer now fails with 0x41.65 left as a partial hex float{0} - -{2}#--------------------------------------------------------------------------{0} -{2}# Support for ?PATTERN? without explicit operator has been removed{0} -{2}#--------------------------------------------------------------------------{0} -{2}# ?PATTERN? must now be written as m?PATTERN?{0} - -{10}?{11}PATTERN{10}?{0} {2}# does not work in current LexPerl anyway, NO ACTION NEEDED{0} +{2}# additional test cases for characterization +{4}0x1p-1074{10}.{0} {2}# dot is a string operator +{4}0x.ABCDEFp10{0} {2}# legal, dot immediately after 0x +{4}0x{10}.{11}p10{0} {2}# perl allows 0x as a zero, then concat with p10 bareword +{4}0x{10}.{11}p{0} {4}0x0{10}.{11}p{0} {2}# dot then bareword +{4}0x_0_.A_BC___DEF_p1_0{0} {2}# legal hex float, underscores are mostly allowed +{4}0x0{10}.{11}_ABCDEFp10{0} {2}# _ABCDEFp10 is a bareword, no underscore allowed after dot +{0} +{2}# illegal, but does not use error highlighting +{4}0x0p1{11}ABC{0} {2}# illegal, highlighted as 0x0p1 abut with bareword ABC +{0} +{2}# allowed to FAIL for now +{4}0x0.ABCDEFp_10{0} {2}# ABCDEFp_10 is a bareword, '_10' exponent not allowed +{4}0xp{0} {4}0xp1{0} {4}0x0.0p{0} {2}# syntax errors +{4}0x41.65{10}.{4}65{0} {2}# hex dot number, but lexer now fails with 0x41.65 left as a partial hex float +{0} +{2}#-------------------------------------------------------------------------- +# Support for ?PATTERN? without explicit operator has been removed +#-------------------------------------------------------------------------- +# ?PATTERN? must now be written as m?PATTERN? +{0} +{10}?{11}PATTERN{10}?{0} {2}# does not work in current LexPerl anyway, NO ACTION NEEDED {17}m?PATTERN?{0} -{2}#--------------------------------------------------------------------------{0} -{2}# end of test file{0} -{2}#--------------------------------------------------------------------------{0} +{2}#-------------------------------------------------------------------------- +# end of test file +#-------------------------------------------------------------------------- diff --git a/test/examples/perl-test-sub-prototypes.pl.styled b/test/examples/perl-test-sub-prototypes.pl.styled index 96d578846..e7290803b 100644 --- a/test/examples/perl-test-sub-prototypes.pl.styled +++ b/test/examples/perl-test-sub-prototypes.pl.styled @@ -1,190 +1,190 @@ -{2}# -*- coding: utf-8 -*-{0} -{2}#--------------------------------------------------------------------------{0} -{2}# perl-test-sub-prototypes.pl{0} -{2}#--------------------------------------------------------------------------{0} -{2}# compiled all relevant subroutine prototype test cases{0} -{2}#{0} -{2}#--------------------------------------------------------------------------{0} -{2}# Kein-Hong Man <keinhong@gmail.com> Public Domain{0} -{2}#--------------------------------------------------------------------------{0} -{2}# 20151227 initial document{0} -{2}#--------------------------------------------------------------------------{0} - -{2}#--------------------------------------------------------------------------{0} -{2}# test cases for sub syntax scanner{0} -{2}#--------------------------------------------------------------------------{0} -{2}# sub syntax: simple and with added module notation{0} -{2}#--------------------------------------------------------------------------{0} - +{2}# -*- coding: utf-8 -*- +#-------------------------------------------------------------------------- +# perl-test-sub-prototypes.pl +#-------------------------------------------------------------------------- +# compiled all relevant subroutine prototype test cases +# +#-------------------------------------------------------------------------- +# Kein-Hong Man <keinhong@gmail.com> Public Domain +#-------------------------------------------------------------------------- +# 20151227 initial document +#-------------------------------------------------------------------------- +{0} +{2}#-------------------------------------------------------------------------- +# test cases for sub syntax scanner +#-------------------------------------------------------------------------- +# sub syntax: simple and with added module notation +#-------------------------------------------------------------------------- +{0} {5}sub{0} {11}fish{40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} -{5}sub{0} {11}fish{10}::{11}chips{40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# module syntax{0} -{5}sub{0} {11}fish{10}::{11}chips{10}::{11}sauce{40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# multiple module syntax{0} - -{5}sub{0} {11}fish{0} {10}::{0} {11}chips{0} {10}::{0} {11}sauce{0} {40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# added whitespace{0} - -{5}sub{0} {11}fish{0} {10}::{0} {2}# embedded comment{0} -{11}chips{0} {2}# embedded comment{0} - {10}::{0} {11}sauce{0} {40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} - -{5}sub{0} {11}fish{0} {10}::{0} {10}({12}$){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# incomplete or bad syntax examples{0} +{5}sub{0} {11}fish{10}::{11}chips{40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# module syntax +{5}sub{0} {11}fish{10}::{11}chips{10}::{11}sauce{40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# multiple module syntax +{0} +{5}sub{0} {11}fish{0} {10}::{0} {11}chips{0} {10}::{0} {11}sauce{0} {40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# added whitespace +{0} +{5}sub{0} {11}fish{0} {10}::{0} {2}# embedded comment +{11}chips{0} {2}# embedded comment +{0} {10}::{0} {11}sauce{0} {40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} + +{5}sub{0} {11}fish{0} {10}::{0} {10}({12}$){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# incomplete or bad syntax examples {5}sub{0} {11}fish{0} {10}::{0} {4}123{0} {10}({12}$){0} {10}{{0} {4}123{10};{0} {10}}{0} {5}sub{0} {11}fish{0} {10}::{0} {11}chips{0} {4}123{0} {10}({12}$){0} {10}{{0} {4}123{10};{0} {10}}{0} {5}sub{0} {4}123{0} {10}({12}$){0} {10}{{0} {4}123{10};{0} {10}}{0} -{2}#--------------------------------------------------------------------------{0} -{2}# sub syntax: prototype attributes{0} -{2}#--------------------------------------------------------------------------{0} - +{2}#-------------------------------------------------------------------------- +# sub syntax: prototype attributes +#-------------------------------------------------------------------------- +{0} {5}sub{0} {11}fish{10}:{5}prototype{40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} -{5}sub{0} {11}fish{0} {10}:{0} {5}prototype{0} {40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# added whitespace{0} - -{5}sub{0} {11}fish{10}:{11}salted{10}({12}$){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# wrong attribute example (must use 'prototype'){0} -{5}sub{0} {11}fish{0} {10}:{0} {4}123{10}({12}$){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# illegal attribute{0} -{5}sub{0} {11}fish{10}:{5}prototype{10}:{11}salted{10}({12}$){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# wrong 'prototype' position{0} -{5}sub{0} {11}fish{10}:{11}salted{0} {11}salt{10}:{5}prototype{10}({12}$){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# wrong attribute syntax{0} - -{5}sub{0} {11}fish{10}:{11}const{10}:{5}prototype{40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# extra attributes{0} +{5}sub{0} {11}fish{0} {10}:{0} {5}prototype{0} {40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# added whitespace +{0} +{5}sub{0} {11}fish{10}:{11}salted{10}({12}$){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# wrong attribute example (must use 'prototype') +{5}sub{0} {11}fish{0} {10}:{0} {4}123{10}({12}$){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# illegal attribute +{5}sub{0} {11}fish{10}:{5}prototype{10}:{11}salted{10}({12}$){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# wrong 'prototype' position +{5}sub{0} {11}fish{10}:{11}salted{0} {11}salt{10}:{5}prototype{10}({12}$){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# wrong attribute syntax +{0} +{5}sub{0} {11}fish{10}:{11}const{10}:{5}prototype{40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# extra attributes {5}sub{0} {11}fish{10}:{11}const{10}:{11}lvalue{10}:{5}prototype{40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} -{5}sub{0} {11}fish{10}:{11}const{10}:{5}prototype{40}($){10}:{11}lvalue{10}{{0} {4}123{10};{0} {10}}{0} {2}# might be legal too{0} -{5}sub{0} {11}fish{0} {10}:{11}const{0} {10}:{5}prototype{40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# extra whitespace{0} - -{5}sub{0} {11}fish{0} {10}:{11}const{0} {2}# embedded comment: a constant sub{0} -{10}:{5}prototype{0} {2}# embedded comment{0} +{5}sub{0} {11}fish{10}:{11}const{10}:{5}prototype{40}($){10}:{11}lvalue{10}{{0} {4}123{10};{0} {10}}{0} {2}# might be legal too +{5}sub{0} {11}fish{0} {10}:{11}const{0} {10}:{5}prototype{40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# extra whitespace +{0} +{5}sub{0} {11}fish{0} {10}:{11}const{0} {2}# embedded comment: a constant sub +{10}:{5}prototype{0} {2}# embedded comment {40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} -{2}#--------------------------------------------------------------------------{0} -{2}# sub syntax: mixed{0} -{2}#--------------------------------------------------------------------------{0} - +{2}#-------------------------------------------------------------------------- +# sub syntax: mixed +#-------------------------------------------------------------------------- +{0} {5}sub{0} {11}fish{10}::{11}chips{10}:{5}prototype{40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} {5}sub{0} {11}fish{10}::{11}chips{10}::{11}sauce{10}:{5}prototype{40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} -{5}sub{0} {11}fish{0} {10}::{11}chips{0} {10}::{11}sauce{0} {10}:{5}prototype{40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# +whitespace{0} - +{5}sub{0} {11}fish{0} {10}::{11}chips{0} {10}::{11}sauce{0} {10}:{5}prototype{40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# +whitespace +{0} {5}sub{0} {11}fish{10}::{11}chips{10}::{11}sauce{10}:{11}const{10}:{5}prototype{40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} -{5}sub{0} {11}fish{10}::{11}chips{10}::{11}sauce{0} {10}:{11}const{0} {10}:{5}prototype{40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# +whitespace{0} - -{5}sub{0} {11}fish{0} {2}# embedded comment{0} -{10}::{11}chips{0} {10}::{11}sauce{0} {2}# embedded comment{0} - {10}:{0} {11}const{0} {2}# embedded comment{0} - {10}:{0} {5}prototype{0} {40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} - -{2}# wrong syntax examples, parentheses must follow ':prototype'{0} +{5}sub{0} {11}fish{10}::{11}chips{10}::{11}sauce{0} {10}:{11}const{0} {10}:{5}prototype{40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} {2}# +whitespace +{0} +{5}sub{0} {11}fish{0} {2}# embedded comment +{10}::{11}chips{0} {10}::{11}sauce{0} {2}# embedded comment +{0} {10}:{0} {11}const{0} {2}# embedded comment +{0} {10}:{0} {5}prototype{0} {40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} + +{2}# wrong syntax examples, parentheses must follow ':prototype' {5}sub{0} {11}fish{0} {10}:{5}prototype{0} {10}:{11}const{0} {10}({12}$){0} {10}{{0} {4}123{10};}{0} {5}sub{0} {11}fish{0} {10}:{5}prototype{0} {10}::{11}chips{0} {10}({12}$){0} {10}{{0} {4}123{10};}{0} -{2}#--------------------------------------------------------------------------{0} -{2}# perl-test-5200delta.pl{0} -{2}#--------------------------------------------------------------------------{0} -{2}# More consistent prototype parsing{0} -{2}#--------------------------------------------------------------------------{0} -{2}# - whitespace now allowed, lexer now allows spaces or tabs{0} - +{2}#-------------------------------------------------------------------------- +# perl-test-5200delta.pl +#-------------------------------------------------------------------------- +# More consistent prototype parsing +#-------------------------------------------------------------------------- +# - whitespace now allowed, lexer now allows spaces or tabs +{0} {5}sub{0} {11}foo{0} {40}( $ $ ){0} {10}{}{0} -{5}sub{0} {11}foo{0} {40}( ){0} {10}{}{0} {2}# spaces/tabs empty{0} +{5}sub{0} {11}foo{0} {40}( ){0} {10}{}{0} {2}# spaces/tabs empty {5}sub{0} {11}foo{0} {40}( * ){0} {10}{}{0} {5}sub{0} {11}foo{0} {40}(@ ){0} {10}{}{0} {5}sub{0} {11}foo{0} {40}( %){0} {10}{}{0} -{2}# untested, should probably be \[ but scanner does not check this for now{0} +{2}# untested, should probably be \[ but scanner does not check this for now {5}sub{0} {11}foo{0} {40}( \ [ $ @ % & * ] ){0} {10}{}{0} -{2}#--------------------------------------------------------------------------{0} -{2}# perl-test-5140delta.pl{0} -{2}#--------------------------------------------------------------------------{0} -{2}# new + prototype character, acts like (\[@%]){0} -{2}#--------------------------------------------------------------------------{0} - -{2}# these samples work as before{0} -{5}sub{0} {11}mylink{0} {40}($$){0} {2}# mylink $old, $new{0} -{5}sub{0} {11}myvec{0} {40}($$$){0} {2}# myvec $var, $offset, 1{0} -{5}sub{0} {11}myindex{0} {40}($$;$){0} {2}# myindex &getstring, "substr"{0} -{5}sub{0} {11}mysyswrite{0} {40}($$$;$){0} {2}# mysyswrite $buf, 0, length($buf) - $off, $off{0} -{5}sub{0} {11}myreverse{0} {40}(@){0} {2}# myreverse $a, $b, $c{0} -{5}sub{0} {11}myjoin{0} {40}($@){0} {2}# myjoin ":", $a, $b, $c{0} -{5}sub{0} {11}myopen{0} {40}(*;$){0} {2}# myopen HANDLE, $name{0} -{5}sub{0} {11}mypipe{0} {40}(**){0} {2}# mypipe READHANDLE, WRITEHANDLE{0} -{5}sub{0} {11}mygrep{0} {40}(&@){0} {2}# mygrep { /foo/ } $a, $b, $c{0} -{5}sub{0} {11}myrand{0} {40}(;$){0} {2}# myrand 42{0} -{5}sub{0} {11}mytime{0} {40}(){0} {2}# mytime{0} - -{2}# backslash group notation to specify more than one allowed argument type{0} +{2}#-------------------------------------------------------------------------- +# perl-test-5140delta.pl +#-------------------------------------------------------------------------- +# new + prototype character, acts like (\[@%]) +#-------------------------------------------------------------------------- +{0} +{2}# these samples work as before +{5}sub{0} {11}mylink{0} {40}($$){0} {2}# mylink $old, $new +{5}sub{0} {11}myvec{0} {40}($$$){0} {2}# myvec $var, $offset, 1 +{5}sub{0} {11}myindex{0} {40}($$;$){0} {2}# myindex &getstring, "substr" +{5}sub{0} {11}mysyswrite{0} {40}($$$;$){0} {2}# mysyswrite $buf, 0, length($buf) - $off, $off +{5}sub{0} {11}myreverse{0} {40}(@){0} {2}# myreverse $a, $b, $c +{5}sub{0} {11}myjoin{0} {40}($@){0} {2}# myjoin ":", $a, $b, $c +{5}sub{0} {11}myopen{0} {40}(*;$){0} {2}# myopen HANDLE, $name +{5}sub{0} {11}mypipe{0} {40}(**){0} {2}# mypipe READHANDLE, WRITEHANDLE +{5}sub{0} {11}mygrep{0} {40}(&@){0} {2}# mygrep { /foo/ } $a, $b, $c +{5}sub{0} {11}myrand{0} {40}(;$){0} {2}# myrand 42 +{5}sub{0} {11}mytime{0} {40}(){0} {2}# mytime +{0} +{2}# backslash group notation to specify more than one allowed argument type {5}sub{0} {11}myref{0} {40}(\[$@%&*]){0} {10}{}{0} -{5}sub{0} {11}mysub{0} {40}(_){0} {2}# underscore can be optionally used FIXED 20151211{0} - -{2}# these uses the new '+' prototype character{0} -{5}sub{0} {11}mypop{0} {40}(+){0} {2}# mypop @array{0} -{5}sub{0} {11}mysplice{0} {40}(+$$@){0} {2}# mysplice @array, 0, 2, @pushme{0} -{5}sub{0} {11}mykeys{0} {40}(+){0} {2}# mykeys %{$hashref}{0} - -{2}#--------------------------------------------------------------------------{0} -{2}# perl-test-5200delta.pl{0} -{2}#--------------------------------------------------------------------------{0} -{2}# Experimental Subroutine signatures (mostly works){0} -{2}#--------------------------------------------------------------------------{0} -{2}# INCLUDED FOR COMPLETENESS ONLY{0} -{2}# IMPORTANT NOTE the subroutine prototypes lexing implementation has{0} -{2}# no effect on subroutine signature syntax highlighting{0} - -{2}# subroutine signatures mostly looks fine except for the @ and % slurpy{0} -{2}# notation which are highlighted as operators (all other parameters are{0} -{2}# highlighted as vars of some sort), a minor aesthetic issue{0} - +{5}sub{0} {11}mysub{0} {40}(_){0} {2}# underscore can be optionally used FIXED 20151211 +{0} +{2}# these uses the new '+' prototype character +{5}sub{0} {11}mypop{0} {40}(+){0} {2}# mypop @array +{5}sub{0} {11}mysplice{0} {40}(+$$@){0} {2}# mysplice @array, 0, 2, @pushme +{5}sub{0} {11}mykeys{0} {40}(+){0} {2}# mykeys %{$hashref} +{0} +{2}#-------------------------------------------------------------------------- +# perl-test-5200delta.pl +#-------------------------------------------------------------------------- +# Experimental Subroutine signatures (mostly works) +#-------------------------------------------------------------------------- +# INCLUDED FOR COMPLETENESS ONLY +# IMPORTANT NOTE the subroutine prototypes lexing implementation has +# no effect on subroutine signature syntax highlighting +{0} +{2}# subroutine signatures mostly looks fine except for the @ and % slurpy +# notation which are highlighted as operators (all other parameters are +# highlighted as vars of some sort), a minor aesthetic issue +{0} {5}use{0} {11}feature{0} {7}'signatures'{10};{0} -{5}sub{0} {11}foo{0} {10}({12}$left{10},{0} {12}$right{10}){0} {10}{{0} {2}# mandatory positional parameters{0} - {5}return{0} {12}$left{0} {10}+{0} {12}$right{10};{0} +{5}sub{0} {11}foo{0} {10}({12}$left{10},{0} {12}$right{10}){0} {10}{{0} {2}# mandatory positional parameters +{0} {5}return{0} {12}$left{0} {10}+{0} {12}$right{10};{0} {10}}{0} -{5}sub{0} {11}foo{0} {10}({12}$first{10},{0} {12}$,{0} {12}$third{10}){0} {10}{{0} {2}# ignore second argument{0} - {5}return{0} {6}"first={43}$first{6}, third={43}$third{6}"{10};{0} +{5}sub{0} {11}foo{0} {10}({12}$first{10},{0} {12}$,{0} {12}$third{10}){0} {10}{{0} {2}# ignore second argument +{0} {5}return{0} {6}"first={43}$first{6}, third={43}$third{6}"{10};{0} {10}}{0} -{5}sub{0} {11}foo{0} {10}({12}$left{10},{0} {12}$right{0} {10}={0} {4}0{10}){0} {10}{{0} {2}# optional parameter with default value{0} - {5}return{0} {12}$left{0} {10}+{0} {12}$right{10};{0} +{5}sub{0} {11}foo{0} {10}({12}$left{10},{0} {12}$right{0} {10}={0} {4}0{10}){0} {10}{{0} {2}# optional parameter with default value +{0} {5}return{0} {12}$left{0} {10}+{0} {12}$right{10};{0} {10}}{0} -{5}my{0} {12}$auto_id{0} {10}={0} {4}0{10};{0} {2}# default value expression, evaluated if default used only{0} +{5}my{0} {12}$auto_id{0} {10}={0} {4}0{10};{0} {2}# default value expression, evaluated if default used only {5}sub{0} {11}foo{0} {10}({12}$thing{10},{0} {12}$id{0} {10}={0} {12}$auto_id{10}++){0} {10}{{0} {5}print{0} {6}"{43}$thing{6} has ID {43}$id{6}"{10};{0} {10}}{0} -{5}sub{0} {11}foo{0} {10}({12}$first_name{10},{0} {12}$surname{10},{0} {12}$nickname{0} {10}={0} {12}$first_name{10}){0} {10}{{0} {2}# 3rd parm may depend on 1st parm{0} - {5}print{0} {6}"{43}$first_name{6} {43}$surname{6} is known as \"{43}$nickname{6}\""{10};{0} +{5}sub{0} {11}foo{0} {10}({12}$first_name{10},{0} {12}$surname{10},{0} {12}$nickname{0} {10}={0} {12}$first_name{10}){0} {10}{{0} {2}# 3rd parm may depend on 1st parm +{0} {5}print{0} {6}"{43}$first_name{6} {43}$surname{6} is known as \"{43}$nickname{6}\""{10};{0} {10}}{0} -{5}sub{0} {11}foo{0} {10}({12}$thing{10},{0} {12}${0} {10}={0} {4}1{10}){0} {10}{{0} {2}# nameless default parameter{0} - {5}print{0} {12}$thing{10};{0} +{5}sub{0} {11}foo{0} {10}({12}$thing{10},{0} {12}${0} {10}={0} {4}1{10}){0} {10}{{0} {2}# nameless default parameter +{0} {5}print{0} {12}$thing{10};{0} {10}}{0} -{5}sub{0} {11}foo{0} {10}({12}$thing{10},{0} {12}$={10}){0} {10}{{0} {2}# (this does something, I'm not sure what...){0} - {5}print{0} {12}$thing{10};{0} +{5}sub{0} {11}foo{0} {10}({12}$thing{10},{0} {12}$={10}){0} {10}{{0} {2}# (this does something, I'm not sure what...) +{0} {5}print{0} {12}$thing{10};{0} {10}}{0} -{5}sub{0} {11}foo{0} {10}({12}$filter{10},{0} {13}@inputs{10}){0} {10}{{0} {2}# additional arguments (slurpy parameter){0} - {5}print{0} {12}$filter{10}->({12}$_{10}){0} {5}foreach{0} {13}@inputs{10};{0} +{5}sub{0} {11}foo{0} {10}({12}$filter{10},{0} {13}@inputs{10}){0} {10}{{0} {2}# additional arguments (slurpy parameter) +{0} {5}print{0} {12}$filter{10}->({12}$_{10}){0} {5}foreach{0} {13}@inputs{10};{0} {10}}{0} -{5}sub{0} {11}foo{0} {10}({12}$thing{10},{0} {10}@){0} {10}{{0} {2}# nameless slurpy parameter FAILS for now{0} - {5}print{0} {12}$thing{10};{0} +{5}sub{0} {11}foo{0} {10}({12}$thing{10},{0} {10}@){0} {10}{{0} {2}# nameless slurpy parameter FAILS for now +{0} {5}print{0} {12}$thing{10};{0} {10}}{0} -{5}sub{0} {11}foo{0} {10}({12}$filter{10},{0} {14}%inputs{10}){0} {10}{{0} {2}# slurpy parameter, hash type{0} - {5}print{0} {12}$filter{10}->({12}$_{10},{0} {12}$inputs{10}{{12}$_{10}}){0} {5}foreach{0} {5}sort{0} {5}keys{0} {14}%inputs{10};{0} +{5}sub{0} {11}foo{0} {10}({12}$filter{10},{0} {14}%inputs{10}){0} {10}{{0} {2}# slurpy parameter, hash type +{0} {5}print{0} {12}$filter{10}->({12}$_{10},{0} {12}$inputs{10}{{12}$_{10}}){0} {5}foreach{0} {5}sort{0} {5}keys{0} {14}%inputs{10};{0} {10}}{0} -{5}sub{0} {11}foo{0} {10}({12}$thing{10},{0} {10}%){0} {10}{{0} {2}# nameless slurpy parm, hash type FAILS for now{0} - {5}print{0} {12}$thing{10};{0} +{5}sub{0} {11}foo{0} {10}({12}$thing{10},{0} {10}%){0} {10}{{0} {2}# nameless slurpy parm, hash type FAILS for now +{0} {5}print{0} {12}$thing{10};{0} {10}}{0} -{5}sub{0} {11}foo{0} {40}(){0} {10}{{0} {2}# empty signature no arguments (styled as prototype){0} - {5}return{0} {4}123{10};{0} +{5}sub{0} {11}foo{0} {40}(){0} {10}{{0} {2}# empty signature no arguments (styled as prototype) +{0} {5}return{0} {4}123{10};{0} {10}}{0} -{2}#--------------------------------------------------------------------------{0} -{2}# perl-test-5200delta.pl{0} -{2}#--------------------------------------------------------------------------{0} -{2}# subs now take a prototype attribute{0} -{2}#--------------------------------------------------------------------------{0} - +{2}#-------------------------------------------------------------------------- +# perl-test-5200delta.pl +#-------------------------------------------------------------------------- +# subs now take a prototype attribute +#-------------------------------------------------------------------------- +{0} {5}sub{0} {11}foo{0} {10}:{5}prototype{40}($){0} {10}{{0} {12}$_{10}[{4}0{10}]{0} {10}}{0} {5}sub{0} {11}foo{0} {10}:{5}prototype{40}($$){0} {10}({12}$left{10},{0} {12}$right{10}){0} {10}{{0} {5}return{0} {12}$left{0} {10}+{0} {12}$right{10};{0} {10}}{0} -{5}sub{0} {11}foo{0} {10}:{0} {5}prototype{40}($$){10}{}{0} {2}# whitespace allowed{0} - -{2}# additional samples from perl-test-cases.pl with ':prototype' added:{0} +{5}sub{0} {11}foo{0} {10}:{0} {5}prototype{40}($$){10}{}{0} {2}# whitespace allowed +{0} +{2}# additional samples from perl-test-cases.pl with ':prototype' added: {5}sub{0} {11}mylink{0} {10}:{5}prototype{40}($$){0} {10}{}{0} {5}sub{0} {11}myvec{0} {10}:{5}prototype{40}($$$){0} {10}{}{0} {5}sub{0} {11}myindex{0} {10}:{5}prototype{40}($$;$){0} {10}{}{0} {5}sub{0} {11}mysyswrite{0} {10}:{5}prototype{40}($$$;$){0} {10}{}{0} {5}sub{0} {11}myreverse{0} {10}:{5}prototype{40}(@){0} {10}{}{0} {5}sub{0} {11}myjoin{0} {10}:{5}prototype{40}($@){0} {10}{}{0} @@ -192,33 +192,33 @@ {5}sub{0} {11}mykeys{0} {10}:{5}prototype{40}(\%){0} {10}{}{0} {5}sub{0} {11}myopen{0} {10}:{5}prototype{40}(*;$){0} {10}{}{0} {5}sub{0} {11}mypipe{0} {10}:{5}prototype{40}(**){0} {10}{}{0} {5}sub{0} {11}mygrep{0} {10}:{5}prototype{40}(&@){0} {10}{}{0} {5}sub{0} {11}myrand{0} {10}:{5}prototype{40}($){0} {10}{}{0} {5}sub{0} {11}mytime{0} {10}:{5}prototype{40}(){0} {10}{}{0} -{2}# backslash group notation to specify more than one allowed argument type{0} +{2}# backslash group notation to specify more than one allowed argument type {5}sub{0} {11}myref{0} {10}:{5}prototype{40}(\[$@%&*]){0} {10}{}{0} -{2}# additional attributes may complicate scanning for prototype syntax,{0} -{2}# for example (from https://metacpan.org/pod/perlsub):{0} -{2}# Lvalue subroutines{0} - +{2}# additional attributes may complicate scanning for prototype syntax, +# for example (from https://metacpan.org/pod/perlsub): +# Lvalue subroutines +{0} {5}my{0} {12}$val{10};{0} {5}sub{0} {11}canmod{0} {10}:{0} {11}lvalue{0} {10}{{0} - {12}$val{10};{0} {2}# or: return $val;{0} + {12}$val{10};{0} {2}# or: return $val; {10}}{0} -{11}canmod{10}(){0} {10}={0} {4}5{10};{0} {2}# assigns to $val{0} - -{2}#--------------------------------------------------------------------------{0} -{2}# perl-test-5220delta.pl{0} -{2}#--------------------------------------------------------------------------{0} -{2}# New :const subroutine attribute{0} -{2}#--------------------------------------------------------------------------{0} - +{11}canmod{10}(){0} {10}={0} {4}5{10};{0} {2}# assigns to $val +{0} +{2}#-------------------------------------------------------------------------- +# perl-test-5220delta.pl +#-------------------------------------------------------------------------- +# New :const subroutine attribute +#-------------------------------------------------------------------------- +{0} {5}my{0} {12}$x{0} {10}={0} {4}54321{10};{0} {15}*INLINED{0} {10}={0} {5}sub{0} {10}:{0} {11}const{0} {10}{{0} {12}$x{0} {10}};{0} {12}$x{10}++;{0} -{2}# more examples of attributes{0} -{2}# (not 5.22 stuff, but some general examples for study, useful for{0} -{2}# handling subroutine signature and subroutine prototype highlighting){0} - +{2}# more examples of attributes +# (not 5.22 stuff, but some general examples for study, useful for +# handling subroutine signature and subroutine prototype highlighting) +{0} {5}sub{0} {11}foo{0} {10}:{0} {11}lvalue{0} {10};{0} {5}package{0} {11}X{10};{0} @@ -231,9 +231,9 @@ {5}package{0} {11}Z{10};{0} {5}sub{0} {11}Y{10}::{11}bar{0} {10}:{0} {11}lvalue{0} {10};{0} -{2}# built-in attributes for subroutines:{0} +{2}# built-in attributes for subroutines: {11}lvalue{0} {11}method{0} {5}prototype{10}(..){0} {11}locked{0} {11}const{0} -{2}#--------------------------------------------------------------------------{0} -{2}# end of test file{0} -{2}#--------------------------------------------------------------------------{0} +{2}#-------------------------------------------------------------------------- +# end of test file +#-------------------------------------------------------------------------- |