diff options
39 files changed, 1259 insertions, 0 deletions
diff --git a/lexilla/test/examples/cpp/SciTE.properties b/lexilla/test/examples/cpp/SciTE.properties new file mode 100644 index 000000000..ea4dd39b8 --- /dev/null +++ b/lexilla/test/examples/cpp/SciTE.properties @@ -0,0 +1,4 @@ +lexer.*.cxx=cpp +keywords.*.cxx=int +keywords2.*.cxx= +lexer.cpp.track.preprocessor=1
\ No newline at end of file diff --git a/lexilla/test/examples/cpp/x.cxx b/lexilla/test/examples/cpp/x.cxx new file mode 100644 index 000000000..384997072 --- /dev/null +++ b/lexilla/test/examples/cpp/x.cxx @@ -0,0 +1,16 @@ +// A demonstration program +#include <stdio.h> +#if 0 /* */ +#define DUMMY() \ + if (1); +#endif + +#define M\ + +\ + +int main() { + double x[] = {3.14159,6.02e23,1.6e-19,1.0+1}; + int y[] = {75,0113,0x4b}; + printf("hello world %d %g\n", y[0], x[0]); +} diff --git a/lexilla/test/examples/cpp/x.cxx.styled b/lexilla/test/examples/cpp/x.cxx.styled new file mode 100644 index 000000000..b602717a5 --- /dev/null +++ b/lexilla/test/examples/cpp/x.cxx.styled @@ -0,0 +1,16 @@ +{2}// A demonstration program +{9}#include <stdio.h> +#if 0 {23}/* */{9} +{73}#define DUMMY() \ + if (1); +{9}#endif +{0} +{9}#define M\ + +{0}\ + +{5}int{0} {11}main{10}(){0} {10}{{0} + {11}double{0} {11}x{10}[]{0} {10}={0} {10}{{4}3.14159{10},{4}6.02e23{10},{4}1.6e-19{10},{4}1.0{10}+{4}1{10}};{0} + {5}int{0} {11}y{10}[]{0} {10}={0} {10}{{4}75{10},{4}0113{10},{4}0x4b{10}};{0} + {11}printf{10}({6}"hello world %d %g\n"{10},{0} {11}y{10}[{4}0{10}],{0} {11}x{10}[{4}0{10}]);{0} +{10}}{0} diff --git a/lexilla/test/examples/d/SciTE.properties b/lexilla/test/examples/d/SciTE.properties new file mode 100644 index 000000000..5db047ab5 --- /dev/null +++ b/lexilla/test/examples/d/SciTE.properties @@ -0,0 +1,9 @@ +lexer.*.d=d +keywords.*.d=keyword1 +keywords2.*.d=keyword2 +keywords3.*.d= +keywords4.*.d=keyword4 +keywords5.*.d=keyword5 +keywords6.*.d=keyword6 +keywords7.*.d=keyword7 + diff --git a/lexilla/test/examples/d/x.d b/lexilla/test/examples/d/x.d new file mode 100644 index 000000000..617aa38a1 --- /dev/null +++ b/lexilla/test/examples/d/x.d @@ -0,0 +1,47 @@ +$ +// /++ +/ doccomments are not yet supported +/* */ +/** */ +/// drdr +/+ /+ +/ +/ +//keyword test +keyword1 +keyword2 +keyword4 +keyword5 +keyword6 +keyword7 +//unicode identifier test +вапёasdÓΘΣαԷԸՑהכ拉麺とひシマイ단결을 +//strings test +'s +' +w's'w +"multiline + string"w +e"zz"e +r"asd\"e +r"multiline + string"c +r`asd\`e +`multiline + string`d +x"023 abc"e +x"023 + abc"w +//numbers test +a[3..4]=3 +2.stringof +2.0.stringof +2. +2.2e+2 +2.2e-2 +.2e+2 +.2 +2e+2 +0x2e+2 +0x2ep+10 +,.2.stringof, + +end + diff --git a/lexilla/test/examples/d/x.d.styled b/lexilla/test/examples/d/x.d.styled new file mode 100644 index 000000000..32e4556dd --- /dev/null +++ b/lexilla/test/examples/d/x.d.styled @@ -0,0 +1,47 @@ +{14}${0} +{2}// /++ +/ doccomments are not yet supported +{1}/* */{0} +{3}/** */{0} +{15}/// drdr +{4}/+ /+ +/ +/{0} +{2}//keyword test +{6}keyword1{0} +{7}keyword2{0} +{9}keyword4{0} +{20}keyword5{0} +{21}keyword6{0} +{22}keyword7{0} +{2}//unicode identifier test +{14}вапёasdÓΘΣαԷԸՑהכ拉麺とひシマイ단결을{0} +{2}//strings test +{11}'s +' +{14}w{12}'s'{14}w{0} +{10}"multiline + string"w{0} +{14}e{10}"zz"{14}e{0} +{19}r"asd\"{14}e{0} +{19}r"multiline + string"c{0} +{14}r{18}`asd\`{14}e{0} +{18}`multiline + string`d{0} +{19}x"023 abc"{14}e{0} +{19}x"023 + abc"w{0} +{2}//numbers test +{14}a{13}[{5}3{13}..{5}4{13}]={5}3{0} +{5}2.stringof{0} +{5}2.0{13}.{14}stringof{0} +{5}2.{0} +{5}2.2e+2{0} +{5}2.2e-2{0} +{5}.2e+2{0} +{5}.2{0} +{5}2e+2{0} +{5}0x2e{13}+{5}2{0} +{5}0x2ep+10{0} +{13},{5}.2{13}.{14}stringof{13},{0} + +{14}end{0} + diff --git a/lexilla/test/examples/hypertext/SciTE.properties b/lexilla/test/examples/hypertext/SciTE.properties new file mode 100644 index 000000000..9d34ee95a --- /dev/null +++ b/lexilla/test/examples/hypertext/SciTE.properties @@ -0,0 +1,6 @@ +lexer.*=hypertext +keywords.*=b body content head href html link meta \ +name rel script strong title type xmlns +keywords2.*=function +keywords3.*=sub + diff --git a/lexilla/test/examples/hypertext/x.asp b/lexilla/test/examples/hypertext/x.asp new file mode 100644 index 000000000..a78acdc34 --- /dev/null +++ b/lexilla/test/examples/hypertext/x.asp @@ -0,0 +1,12 @@ +<%@language=javas%> +<% +#include +function x() { +} +%> +<%@language=vbscript%> +<% +sub x 'comment +%> +<head> +<body></body> diff --git a/lexilla/test/examples/hypertext/x.asp.styled b/lexilla/test/examples/hypertext/x.asp.styled new file mode 100644 index 000000000..920c6380d --- /dev/null +++ b/lexilla/test/examples/hypertext/x.asp.styled @@ -0,0 +1,12 @@ +{15}<%@{16}language=javas{15}%>{0} +{15}<%{56} +#{61}include{56} +{62}function{56} {61}x{65}(){56} {65}{{56} +{65}}{56} +{15}%>{0} +{15}<%@{16}language=vbscript{15}%>{0} +{15}<%{81} +{84}sub{81} {86}x{81} {82}'comment {81} +{15}%>{0} +{1}<head>{0} +{1}<body></body>{0} diff --git a/lexilla/test/examples/hypertext/x.html b/lexilla/test/examples/hypertext/x.html new file mode 100644 index 000000000..caebcf41a --- /dev/null +++ b/lexilla/test/examples/hypertext/x.html @@ -0,0 +1,12 @@ +<html xmlns="http://www.w3.org/1999/xhtml"> +<script type="text/javascript"> +var b = /abc/i.test('abc'); +'x\ +</t>' +</script> +<head> + <meta name="Date.Modified" content="20010515" /> + <title>SinkWorld - Portability</title> + <unknown>SinkWorld - Portability</unknown> + <link rel="stylesheet" type="text/css" href="SW.css"> +</head> diff --git a/lexilla/test/examples/hypertext/x.html.styled b/lexilla/test/examples/hypertext/x.html.styled new file mode 100644 index 000000000..3e50a1147 --- /dev/null +++ b/lexilla/test/examples/hypertext/x.html.styled @@ -0,0 +1,12 @@ +{1}<html{8} {3}xmlns{8}={6}"http://www.w3.org/1999/xhtml"{1}>{0} +{1}<script{8} {3}type{8}={6}"text/javascript"{1}>{40} +{46}var{41} {46}b{41} {50}={41} {52}/abc/i{46}.test{50}({49}'abc'{50});{41} +{49}'x\ +</t>'{41} +{1}</script>{0} +{1}<head>{0} + {1}<meta{8} {3}name{8}={6}"Date.Modified"{8} {3}content{8}={6}"20010515"{8} {11}/>{0} + {1}<title>{0}SinkWorld - Portability{1}</title>{0} + {2}<unknown>{0}SinkWorld - Portability{2}</unknown>{0} + {1}<link{8} {3}rel{8}={6}"stylesheet"{8} {3}type{8}={6}"text/css"{8} {3}href{8}={6}"SW.css"{1}>{0} +{1}</head>{0} diff --git a/lexilla/test/examples/hypertext/x.php b/lexilla/test/examples/hypertext/x.php new file mode 100644 index 000000000..bc7302d85 --- /dev/null +++ b/lexilla/test/examples/hypertext/x.php @@ -0,0 +1,6 @@ +<head> <!-- About to script --> +<?php +echo "<!-- -->\n"; +/* ?> */ +?> +<strong>for</strong><b>if</b> diff --git a/lexilla/test/examples/hypertext/x.php.styled b/lexilla/test/examples/hypertext/x.php.styled new file mode 100644 index 000000000..fb90ba06e --- /dev/null +++ b/lexilla/test/examples/hypertext/x.php.styled @@ -0,0 +1,6 @@ +{1}<head>{0} {9}<!-- About to script -->{0} +{18}<?php{118} +echo {119}"<!-- -->\n"{127};{118} +{124}/* ?> */{118} +{18}?>{0} +{1}<strong>{0}for{1}</strong><b>{0}if{1}</b>{0} diff --git a/lexilla/test/examples/lua/SciTE.properties b/lexilla/test/examples/lua/SciTE.properties new file mode 100644 index 000000000..ae8c7ab91 --- /dev/null +++ b/lexilla/test/examples/lua/SciTE.properties @@ -0,0 +1,2 @@ +lexer.*.lua=lua +keywords.*.lua=function end diff --git a/lexilla/test/examples/lua/x.lua b/lexilla/test/examples/lua/x.lua new file mode 100644 index 000000000..cfa3537b5 --- /dev/null +++ b/lexilla/test/examples/lua/x.lua @@ -0,0 +1,7 @@ +--[[ coding:UTF-8 +comment ]] +function first() +::開:: + -- Comment + func(SCI_ANNOTATIONSETTEXT, 'a', 0, "LINE1") +end diff --git a/lexilla/test/examples/lua/x.lua.styled b/lexilla/test/examples/lua/x.lua.styled new file mode 100644 index 000000000..0c8f76fa4 --- /dev/null +++ b/lexilla/test/examples/lua/x.lua.styled @@ -0,0 +1,7 @@ +{1}--[[ coding:UTF-8 +comment ]]{0} +{5}function{0} {11}first{10}(){0} +{20}::開::{0} + {2}-- Comment +{0} {11}func{10}({11}SCI_ANNOTATIONSETTEXT{10},{0} {7}'a'{10},{0} {4}0{10},{0} {6}"LINE1"{10}){0} +{5}end{0} diff --git a/lexilla/test/examples/nim/SciTE.properties b/lexilla/test/examples/nim/SciTE.properties new file mode 100644 index 000000000..3a0214952 --- /dev/null +++ b/lexilla/test/examples/nim/SciTE.properties @@ -0,0 +1,2 @@ +lexer.*.nim=nim +keywords.*.nim=else end if let proc diff --git a/lexilla/test/examples/nim/x.nim b/lexilla/test/examples/nim/x.nim new file mode 100644 index 000000000..874940d47 --- /dev/null +++ b/lexilla/test/examples/nim/x.nim @@ -0,0 +1,28 @@ +# Tests for Nim +let s = "foobar" + +# Feature #1260 +{.ident.} +stdin.readLine.split.map(parseInt).max.`$`.echo(" is the maximum!") + +# Feature #1261 +# IsFuncName("proc") so style ticks as SCE_NIM_FUNCNAME: +proc `$` (x: myDataType): string = ... +# Style ticks as SCE_NIM_BACKTICKS: +if `==`( `+`(3,4),7): echo "True" + +# Feature #1262 +# Standard raw string identifier: +let standardDoubleLitRawStr = R"A raw string\" +let standardTripleLitRawStr = R"""A triple-double raw string\"""" +# Style of 'customIdent' is determined by lexer.nim.raw.strings.highlight.ident. 16 if false, 6 or 10 if true +let customDoubleLitRawStr = customIdent"A string\" +let customTripleLitRawStr = customIdent"""A triple-double raw string\"""" + +# Feature #1268 +10_000 +10__000 +10_ +1....5 +1.ident +1._ident diff --git a/lexilla/test/examples/nim/x.nim.styled b/lexilla/test/examples/nim/x.nim.styled new file mode 100644 index 000000000..3a05c04b8 --- /dev/null +++ b/lexilla/test/examples/nim/x.nim.styled @@ -0,0 +1,28 @@ +{3}# Tests for Nim +{8}let{0} {16}s{0} {15}={0} {6}"foobar"{0} + +{3}# Feature #1260 +{15}{.{16}ident{15}.}{0} +{16}stdin{15}.{16}readLine{15}.{16}split{15}.{16}map{15}({16}parseInt{15}).{16}max{15}.{11}`$`{15}.{16}echo{15}({6}" is the maximum!"{15}){0} + +{3}# Feature #1261 +# IsFuncName("proc") so style ticks as SCE_NIM_FUNCNAME: +{8}proc{0} {12}`$`{0} {15}({16}x{15}:{0} {16}myDataType{15}):{0} {16}string{0} {15}={0} {15}...{0} +{3}# Style ticks as SCE_NIM_BACKTICKS: +{8}if{0} {11}`==`{15}({0} {11}`+`{15}({5}3{15},{5}4{15}),{5}7{15}):{0} {16}echo{0} {6}"True"{0} + +{3}# Feature #1262 +# Standard raw string identifier: +{8}let{0} {16}standardDoubleLitRawStr{0} {15}={0} {6}R"A raw string\"{0} +{8}let{0} {16}standardTripleLitRawStr{0} {15}={0} {10}R"""A triple-double raw string\""""{0} +{3}# Style of 'customIdent' is determined by lexer.nim.raw.strings.highlight.ident. 16 if false, 6 or 10 if true +{8}let{0} {16}customDoubleLitRawStr{0} {15}={0} {16}customIdent{6}"A string\"{0} +{8}let{0} {16}customTripleLitRawStr{0} {15}={0} {16}customIdent{10}"""A triple-double raw string\""""{0} + +{3}# Feature #1268 +{5}10_000{0} +{5}10{16}__000{0} +{5}10{16}_{0} +{5}1{15}....{5}5{0} +{5}1{15}.{16}ident{0} +{5}1{15}.{16}_ident{0} diff --git a/lexilla/test/examples/perl/SciTE.properties b/lexilla/test/examples/perl/SciTE.properties new file mode 100644 index 000000000..0aefae2c9 --- /dev/null +++ b/lexilla/test/examples/perl/SciTE.properties @@ -0,0 +1,31 @@ +lexer.*.pl=perl +keywords.*.pl=\ +NULL __FILE__ __LINE__ __PACKAGE__ __DATA__ __END__ AUTOLOAD \ +BEGIN CORE DESTROY END EQ GE GT INIT LE LT NE CHECK abs accept \ +alarm and atan2 bind binmode bless caller chdir chmod chomp chop \ +chown chr chroot close closedir cmp connect continue cos crypt \ +dbmclose dbmopen defined delete die do dump each else elsif endgrent \ +endhostent endnetent endprotoent endpwent endservent eof eq eval \ +exec exists exit exp fcntl fileno flock for foreach fork format \ +formline ge getc getgrent getgrgid getgrnam gethostbyaddr gethostbyname \ +gethostent getlogin getnetbyaddr getnetbyname getnetent getpeername \ +getpgrp getppid getpriority getprotobyname getprotobynumber getprotoent \ +getpwent getpwnam getpwuid getservbyname getservbyport getservent \ +getsockname getsockopt glob gmtime goto grep gt hex if index \ +int ioctl join keys kill last lc lcfirst le length link listen \ +local localtime lock log lstat lt map mkdir msgctl msgget msgrcv \ +msgsnd my ne next no not oct open opendir or ord our pack package \ +pipe pop pos print printf prototype push quotemeta qu \ +rand read readdir readline readlink readpipe recv redo \ +ref rename require reset return reverse rewinddir rindex rmdir \ +scalar seek seekdir select semctl semget semop send setgrent \ +sethostent setnetent setpgrp setpriority setprotoent setpwent \ +setservent setsockopt shift shmctl shmget shmread shmwrite shutdown \ +sin sleep socket socketpair sort splice split sprintf sqrt srand \ +stat study sub substr symlink syscall sysopen sysread sysseek \ +system syswrite tell telldir tie tied time times truncate \ +uc ucfirst umask undef unless unlink unpack unshift untie until \ +use utime values vec wait waitpid wantarray warn while write \ +xor \ +given when default break say state UNITCHECK __SUB__ fc + diff --git a/lexilla/test/examples/perl/perl-test-5220delta.pl b/lexilla/test/examples/perl/perl-test-5220delta.pl new file mode 100644 index 000000000..a9c80caa2 --- /dev/null +++ b/lexilla/test/examples/perl/perl-test-5220delta.pl @@ -0,0 +1,178 @@ +# -*- 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 +#-------------------------------------------------------------------------- + +use v5.22; # may be needed + +#-------------------------------------------------------------------------- +# New bitwise operators +#-------------------------------------------------------------------------- + +use feature 'bitwise' # enable feature, warning enabled +use experimental "bitwise"; # enable feature, warning disabled + +# numerical operands +10&20 10|20 10^20 ~10 +$a&"8" $a|"8" $a^"8" ~$a ~"8" + +# string operands +'0'&."8" '0'|."8" '0'^."8" ~.'0' ~."8" +# 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 + $a&.10 $a|.10 $a^.10 ~.$a ~.10 + +# assignment variants +$a&=10; $a|=10; $a^=10; +$b&.='20'; $b|.='20'; $b^.='20'; +$c&="30"; $c|="30"; $c^="30"; +$d&.=$e; $d|.=$e; $d^.=$e; + +#-------------------------------------------------------------------------- +# New double-diamond operator +#-------------------------------------------------------------------------- +# <<>> is like <> but each element of @ARGV will be treated as an actual file name + +# example snippet from brian d foy's blog post +while( <<>> ) { # new, safe line input operator + ...; + } + +#-------------------------------------------------------------------------- +# New \b boundaries in regular expressions +#-------------------------------------------------------------------------- + +qr/\b{gcb}/ +qr/\b{wb}/ +qr/\b{sb}/ + +#-------------------------------------------------------------------------- +# Non-Capturing Regular Expression Flag +#-------------------------------------------------------------------------- +# disables capturing and filling in $1, $2, etc + +"hello" =~ /(hi|hello)/n; # $1 is not set + +#-------------------------------------------------------------------------- +# Aliasing via reference +#-------------------------------------------------------------------------- +# Variables and subroutines can now be aliased by assigning to a reference + +\$c = \$d; +\&x = \&y; + +# Aliasing can also be applied to foreach iterator variables + +foreach \%hash (@array_of_hash_refs) { ... } + +# example snippet from brian d foy's blog post + +use feature qw(refaliasing); + +\%other_hash = \%hash; + +use v5.22; +use feature qw(refaliasing); + +foreach \my %hash ( @array_of_hashes ) { # named hash control variable + foreach my $key ( keys %hash ) { # named hash now! + ...; + } + } + +#-------------------------------------------------------------------------- +# New :const subroutine attribute +#-------------------------------------------------------------------------- + +my $x = 54321; +*INLINED = sub : const { $x }; +$x++; + +# more examples of attributes +# (not 5.22 stuff, but some general examples for study, useful for +# handling subroutine signature and subroutine prototype highlighting) + +sub foo : lvalue ; + +package X; +sub Y::x : lvalue { 1 } + +package X; +sub foo { 1 } +package Y; +BEGIN { *bar = \&X::foo; } +package Z; +sub Y::bar : lvalue ; + +# built-in attributes for subroutines: +lvalue method prototype(..) locked const + +#-------------------------------------------------------------------------- +# Repetition in list assignment +#-------------------------------------------------------------------------- + +# example snippet from brian d foy's blog post +use v5.22; +my(undef, $card_num, (undef)x3, $count) = split /:/; + +(undef,undef,$foo) = that_function() +# is equivalent to +((undef)x2, $foo) = that_function() + +#-------------------------------------------------------------------------- +# Floating point parsing has been improved +#-------------------------------------------------------------------------- +# Hexadecimal floating point literals + +# 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 + +0x1p-1074; +0x3.3333333333334p-5; +0xcc.ccccccccccdp-11; +0x1p+1; +0x1p-6; +0x1.b7p-1; +0x1.fffffffffffffp+1023; +0x1p-1022; +0X1.921FB4D12D84AP+1; +0x1.999999999999ap-4; + +# additional test cases for characterization +0x1p-1074. # dot is a string operator +0x.ABCDEFp10 # legal, dot immediately after 0x +0x.p10 # perl allows 0x as a zero, then concat with p10 bareword +0x.p 0x0.p # dot then bareword +0x_0_.A_BC___DEF_p1_0 # legal hex float, underscores are mostly allowed +0x0._ABCDEFp10 # _ABCDEFp10 is a bareword, no underscore allowed after dot + +# illegal, but does not use error highlighting +0x0p1ABC # illegal, highlighted as 0x0p1 abut with bareword ABC + +# allowed to FAIL for now +0x0.ABCDEFp_10 # ABCDEFp_10 is a bareword, '_10' exponent not allowed +0xp 0xp1 0x0.0p # syntax errors +0x41.65.65 # hex dot number, but lexer now fails with 0x41.65 left as a partial hex float + +#-------------------------------------------------------------------------- +# Support for ?PATTERN? without explicit operator has been removed +#-------------------------------------------------------------------------- +# ?PATTERN? must now be written as m?PATTERN? + +?PATTERN? # does not work in current LexPerl anyway, NO ACTION NEEDED +m?PATTERN? + +#-------------------------------------------------------------------------- +# end of test file +#-------------------------------------------------------------------------- diff --git a/lexilla/test/examples/perl/perl-test-5220delta.pl.styled b/lexilla/test/examples/perl/perl-test-5220delta.pl.styled new file mode 100644 index 000000000..3754c8929 --- /dev/null +++ b/lexilla/test/examples/perl/perl-test-5220delta.pl.styled @@ -0,0 +1,178 @@ +{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} +{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} +{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}# assignment variants{0} +{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} + {10}}{0} + +{2}#--------------------------------------------------------------------------{0} +{2}# New \b boundaries in regular expressions{0} +{2}#--------------------------------------------------------------------------{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} + +{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} + +{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} + +{5}use{0} {11}feature{0} {30}qw(refaliasing){10};{0} + +{10}\{14}%other_hash{0} {10}={0} {10}\{14}%hash{10};{0} + +{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} + {10}}{0} + {10}}{0} + +{2}#--------------------------------------------------------------------------{0} +{2}# New :const subroutine attribute{0} +{2}#--------------------------------------------------------------------------{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} + +{5}sub{0} {11}foo{0} {10}:{0} {11}lvalue{0} {10};{0} + +{5}package{0} {11}X{10};{0} +{5}sub{0} {11}Y{10}::{11}x{0} {10}:{0} {11}lvalue{0} {10}{{0} {4}1{0} {10}}{0} + +{5}package{0} {11}X{10};{0} +{5}sub{0} {11}foo{0} {10}{{0} {4}1{0} {10}}{0} +{5}package{0} {11}Y{10};{0} +{5}BEGIN{0} {10}{{0} {15}*bar{0} {10}={0} {10}\&{11}X{10}::{11}foo{10};{0} {10}}{0} +{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} +{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} +{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} +{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} + +{4}0x1p-1074{10};{0} +{4}0x3.3333333333334p-5{10};{0} +{4}0xcc.ccccccccccdp-11{10};{0} +{4}0x1p+1{10};{0} +{4}0x1p-6{10};{0} +{4}0x1.b7p-1{10};{0} +{4}0x1.fffffffffffffp+1023{10};{0} +{4}0x1p-1022{10};{0} +{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} +{17}m?PATTERN?{0} + +{2}#--------------------------------------------------------------------------{0} +{2}# end of test file{0} +{2}#--------------------------------------------------------------------------{0} diff --git a/lexilla/test/examples/perl/perl-test-sub-prototypes.pl b/lexilla/test/examples/perl/perl-test-sub-prototypes.pl new file mode 100644 index 000000000..9cfb488ba --- /dev/null +++ b/lexilla/test/examples/perl/perl-test-sub-prototypes.pl @@ -0,0 +1,239 @@ +# -*- 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 +#-------------------------------------------------------------------------- + +#-------------------------------------------------------------------------- +# test cases for sub syntax scanner +#-------------------------------------------------------------------------- +# sub syntax: simple and with added module notation +#-------------------------------------------------------------------------- + +sub fish($) { 123; } +sub fish::chips($) { 123; } # module syntax +sub fish::chips::sauce($) { 123; } # multiple module syntax + +sub fish :: chips :: sauce ($) { 123; } # added whitespace + +sub fish :: # embedded comment +chips # embedded comment + :: sauce ($) { 123; } + +sub fish :: ($) { 123; } # incomplete or bad syntax examples +sub fish :: 123 ($) { 123; } +sub fish :: chips 123 ($) { 123; } +sub 123 ($) { 123; } + +#-------------------------------------------------------------------------- +# sub syntax: prototype attributes +#-------------------------------------------------------------------------- + +sub fish:prototype($) { 123; } +sub fish : prototype ($) { 123; } # added whitespace + +sub fish:salted($) { 123; } # wrong attribute example (must use 'prototype') +sub fish : 123($) { 123; } # illegal attribute +sub fish:prototype:salted($) { 123; } # wrong 'prototype' position +sub fish:salted salt:prototype($) { 123; } # wrong attribute syntax + +sub fish:const:prototype($) { 123; } # extra attributes +sub fish:const:lvalue:prototype($) { 123; } +sub fish:const:prototype($):lvalue{ 123; } # might be legal too +sub fish :const :prototype($) { 123; } # extra whitespace + +sub fish :const # embedded comment: a constant sub +:prototype # embedded comment +($) { 123; } + +#-------------------------------------------------------------------------- +# sub syntax: mixed +#-------------------------------------------------------------------------- + +sub fish::chips:prototype($) { 123; } +sub fish::chips::sauce:prototype($) { 123; } +sub fish ::chips ::sauce :prototype($) { 123; } # +whitespace + +sub fish::chips::sauce:const:prototype($) { 123; } +sub fish::chips::sauce :const :prototype($) { 123; } # +whitespace + +sub fish # embedded comment +::chips ::sauce # embedded comment + : const # embedded comment + : prototype ($) { 123; } + +# wrong syntax examples, parentheses must follow ':prototype' +sub fish :prototype :const ($) { 123;} +sub fish :prototype ::chips ($) { 123;} + +#-------------------------------------------------------------------------- +# perl-test-5200delta.pl +#-------------------------------------------------------------------------- +# More consistent prototype parsing +#-------------------------------------------------------------------------- +# - whitespace now allowed, lexer now allows spaces or tabs + +sub foo ( $ $ ) {} +sub foo ( ) {} # spaces/tabs empty +sub foo ( * ) {} +sub foo (@ ) {} +sub foo ( %) {} + +# untested, should probably be \[ but scanner does not check this for now +sub foo ( \ [ $ @ % & * ] ) {} + +#-------------------------------------------------------------------------- +# perl-test-5140delta.pl +#-------------------------------------------------------------------------- +# new + prototype character, acts like (\[@%]) +#-------------------------------------------------------------------------- + +# these samples work as before +sub mylink ($$) # mylink $old, $new +sub myvec ($$$) # myvec $var, $offset, 1 +sub myindex ($$;$) # myindex &getstring, "substr" +sub mysyswrite ($$$;$) # mysyswrite $buf, 0, length($buf) - $off, $off +sub myreverse (@) # myreverse $a, $b, $c +sub myjoin ($@) # myjoin ":", $a, $b, $c +sub myopen (*;$) # myopen HANDLE, $name +sub mypipe (**) # mypipe READHANDLE, WRITEHANDLE +sub mygrep (&@) # mygrep { /foo/ } $a, $b, $c +sub myrand (;$) # myrand 42 +sub mytime () # mytime + +# backslash group notation to specify more than one allowed argument type +sub myref (\[$@%&*]) {} + +sub mysub (_) # underscore can be optionally used FIXED 20151211 + +# these uses the new '+' prototype character +sub mypop (+) # mypop @array +sub mysplice (+$$@) # mysplice @array, 0, 2, @pushme +sub mykeys (+) # mykeys %{$hashref} + +#-------------------------------------------------------------------------- +# 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 + +# 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 + +use feature 'signatures'; + +sub foo ($left, $right) { # mandatory positional parameters + return $left + $right; +} +sub foo ($first, $, $third) { # ignore second argument + return "first=$first, third=$third"; +} +sub foo ($left, $right = 0) { # optional parameter with default value + return $left + $right; +} +my $auto_id = 0; # default value expression, evaluated if default used only +sub foo ($thing, $id = $auto_id++) { + print "$thing has ID $id"; +} +sub foo ($first_name, $surname, $nickname = $first_name) { # 3rd parm may depend on 1st parm + print "$first_name $surname is known as \"$nickname\""; +} +sub foo ($thing, $ = 1) { # nameless default parameter + print $thing; +} +sub foo ($thing, $=) { # (this does something, I'm not sure what...) + print $thing; +} +sub foo ($filter, @inputs) { # additional arguments (slurpy parameter) + print $filter->($_) foreach @inputs; +} +sub foo ($thing, @) { # nameless slurpy parameter FAILS for now + print $thing; +} +sub foo ($filter, %inputs) { # slurpy parameter, hash type + print $filter->($_, $inputs{$_}) foreach sort keys %inputs; +} +sub foo ($thing, %) { # nameless slurpy parm, hash type FAILS for now + print $thing; +} +sub foo () { # empty signature no arguments (styled as prototype) + return 123; +} + +#-------------------------------------------------------------------------- +# perl-test-5200delta.pl +#-------------------------------------------------------------------------- +# subs now take a prototype attribute +#-------------------------------------------------------------------------- + +sub foo :prototype($) { $_[0] } + +sub foo :prototype($$) ($left, $right) { + return $left + $right; +} + +sub foo : prototype($$){} # whitespace allowed + +# additional samples from perl-test-cases.pl with ':prototype' added: +sub mylink :prototype($$) {} sub myvec :prototype($$$) {} +sub myindex :prototype($$;$) {} sub mysyswrite :prototype($$$;$) {} +sub myreverse :prototype(@) {} sub myjoin :prototype($@) {} +sub mypop :prototype(\@) {} sub mysplice :prototype(\@$$@) {} +sub mykeys :prototype(\%) {} sub myopen :prototype(*;$) {} +sub mypipe :prototype(**) {} sub mygrep :prototype(&@) {} +sub myrand :prototype($) {} sub mytime :prototype() {} +# backslash group notation to specify more than one allowed argument type +sub myref :prototype(\[$@%&*]) {} + +# additional attributes may complicate scanning for prototype syntax, +# for example (from https://metacpan.org/pod/perlsub): +# Lvalue subroutines + +my $val; +sub canmod : lvalue { + $val; # or: return $val; +} +canmod() = 5; # assigns to $val + +#-------------------------------------------------------------------------- +# perl-test-5220delta.pl +#-------------------------------------------------------------------------- +# New :const subroutine attribute +#-------------------------------------------------------------------------- + +my $x = 54321; +*INLINED = sub : const { $x }; +$x++; + +# more examples of attributes +# (not 5.22 stuff, but some general examples for study, useful for +# handling subroutine signature and subroutine prototype highlighting) + +sub foo : lvalue ; + +package X; +sub Y::z : lvalue { 1 } + +package X; +sub foo { 1 } +package Y; +BEGIN { *bar = \&X::foo; } +package Z; +sub Y::bar : lvalue ; + +# built-in attributes for subroutines: +lvalue method prototype(..) locked const + +#-------------------------------------------------------------------------- +# 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 new file mode 100644 index 000000000..96d578846 --- /dev/null +++ b/lexilla/test/examples/perl/perl-test-sub-prototypes.pl.styled @@ -0,0 +1,239 @@ +{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} + +{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{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} + +{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{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} +{40}($){0} {10}{{0} {4}123{10};{0} {10}}{0} + +{2}#--------------------------------------------------------------------------{0} +{2}# sub syntax: mixed{0} +{2}#--------------------------------------------------------------------------{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{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{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} + +{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} +{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} +{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} +{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}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} +{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} +{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}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} +{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} +{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} +{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} +{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} + +{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}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} +{5}sub{0} {11}mypop{0} {10}:{5}prototype{40}(\@){0} {10}{}{0} {5}sub{0} {11}mysplice{0} {10}:{5}prototype{40}(\@$$@){0} {10}{}{0} +{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} +{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} + +{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} +{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} + +{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} + +{5}sub{0} {11}foo{0} {10}:{0} {11}lvalue{0} {10};{0} + +{5}package{0} {11}X{10};{0} +{5}sub{0} {11}Y{10}::{11}z{0} {10}:{0} {11}lvalue{0} {10}{{0} {4}1{0} {10}}{0} + +{5}package{0} {11}X{10};{0} +{5}sub{0} {11}foo{0} {10}{{0} {4}1{0} {10}}{0} +{5}package{0} {11}Y{10};{0} +{5}BEGIN{0} {10}{{0} {15}*bar{0} {10}={0} {10}\&{11}X{10}::{11}foo{10};{0} {10}}{0} +{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} +{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} diff --git a/lexilla/test/examples/perl/x.pl b/lexilla/test/examples/perl/x.pl new file mode 100644 index 000000000..19288f2c9 --- /dev/null +++ b/lexilla/test/examples/perl/x.pl @@ -0,0 +1,5 @@ +use strict; +while ( $r ) { + printf ( "Example text \n" ); + sleep 1; +}
\ No newline at end of file diff --git a/lexilla/test/examples/perl/x.pl.styled b/lexilla/test/examples/perl/x.pl.styled new file mode 100644 index 000000000..74da4e911 --- /dev/null +++ b/lexilla/test/examples/perl/x.pl.styled @@ -0,0 +1,5 @@ +{5}use{0} {11}strict{10};{0} +{5}while{0} {10}({0} {12}$r{0} {10}){0} {10}{{0} + {5}printf{0} {10}({0} {6}"Example text \n"{0} {10});{0} + {5}sleep{0} {4}1{10};{0} +{10}}
\ No newline at end of file diff --git a/lexilla/test/examples/python/SciTE.properties b/lexilla/test/examples/python/SciTE.properties new file mode 100644 index 000000000..164a30d52 --- /dev/null +++ b/lexilla/test/examples/python/SciTE.properties @@ -0,0 +1,2 @@ +lexer.*.py=python +keywords.*.py=class def else for if import in print return while diff --git a/lexilla/test/examples/python/x.py b/lexilla/test/examples/python/x.py new file mode 100644 index 000000000..12c4b71df --- /dev/null +++ b/lexilla/test/examples/python/x.py @@ -0,0 +1,11 @@ +# Convert all punctuation characters except '_', '*', and '.' into spaces. +def depunctuate(s): + '''A docstring''' + """Docstring 2""" + d = "" + for ch in s: + if ch in 'abcde': + d = d + ch + else: + d = d + " " + return d diff --git a/lexilla/test/examples/python/x.py.new b/lexilla/test/examples/python/x.py.new new file mode 100644 index 000000000..983c3b83c --- /dev/null +++ b/lexilla/test/examples/python/x.py.new @@ -0,0 +1,11 @@ +{1}# Convert all punctuation characters except '_', '*', and '.' into spaces.{0}
+{5}def{0} {9}depunctuate{10}({11}s{10}):{0}
+ {6}'''A docstring'''{0}
+ {7}"""Docstring 2"""{0}
+ {11}d{0} {10}={0} {3}""{0}
+ {5}for{0} {11}ch{0} {5}in{0} {11}s{10}:{0}
+ {5}if{0} {11}ch{0} {5}in{0} {4}'abcde'{10}:{0}
+ {11}d{0} {10}={0} {11}d{0} {10}+{0} {11}ch{0}
+ {5}else{10}:{0}
+ {11}d{0} {10}={0} {11}d{0} {10}+{0} {3}" "{0}
+ {5}return{0} {11}d{0}
diff --git a/lexilla/test/examples/python/x.py.styled b/lexilla/test/examples/python/x.py.styled new file mode 100644 index 000000000..02f94a923 --- /dev/null +++ b/lexilla/test/examples/python/x.py.styled @@ -0,0 +1,11 @@ +{1}# Convert all punctuation characters except '_', '*', and '.' into spaces.{0} +{5}def{0} {9}depunctuate{10}({11}s{10}):{0} + {6}'''A docstring'''{0} + {7}"""Docstring 2"""{0} + {11}d{0} {10}={0} {3}""{0} + {5}for{0} {11}ch{0} {5}in{0} {11}s{10}:{0} + {5}if{0} {11}ch{0} {5}in{0} {4}'abcde'{10}:{0} + {11}d{0} {10}={0} {11}d{0} {10}+{0} {11}ch{0} + {5}else{10}:{0} + {11}d{0} {10}={0} {11}d{0} {10}+{0} {3}" "{0} + {5}return{0} {11}d{0} diff --git a/lexilla/test/examples/ruby/SciTE.properties b/lexilla/test/examples/ruby/SciTE.properties new file mode 100644 index 000000000..a4be7e9c6 --- /dev/null +++ b/lexilla/test/examples/ruby/SciTE.properties @@ -0,0 +1,2 @@ +lexer.*.rb=ruby +keywords.*.rb=class def end diff --git a/lexilla/test/examples/ruby/x.rb b/lexilla/test/examples/ruby/x.rb new file mode 100644 index 000000000..d1bb0f0a8 --- /dev/null +++ b/lexilla/test/examples/ruby/x.rb @@ -0,0 +1,6 @@ +class Demo + def test # A test + i = 1 + puts "Example" + end +end
\ No newline at end of file diff --git a/lexilla/test/examples/ruby/x.rb.styled b/lexilla/test/examples/ruby/x.rb.styled new file mode 100644 index 000000000..904d07dd3 --- /dev/null +++ b/lexilla/test/examples/ruby/x.rb.styled @@ -0,0 +1,6 @@ +{5}class{0} {8}Demo{0} + {5}def{0} {9}test{0} {2}# A test{0} + {11}i{0} {10}={0} {4}1{0} + {11}puts{0} {6}"Example"{0} + {5}end{0} +{5}end
\ No newline at end of file diff --git a/lexilla/test/examples/tcl/SciTE.properties b/lexilla/test/examples/tcl/SciTE.properties new file mode 100644 index 000000000..8cecd97b4 --- /dev/null +++ b/lexilla/test/examples/tcl/SciTE.properties @@ -0,0 +1,2 @@ +lexer.*.tcl=tcl +keywords.*.tcl=proc set socket vwait diff --git a/lexilla/test/examples/tcl/x.tcl b/lexilla/test/examples/tcl/x.tcl new file mode 100644 index 000000000..d1260fc82 --- /dev/null +++ b/lexilla/test/examples/tcl/x.tcl @@ -0,0 +1,13 @@ +# tcl tests + +#simple example + +proc Echo_Server {port} { + set s [socket -server EchoAccept $port] + vwait forever; +} + +# Bug #1947 + +$s($i,"n") +set n $showArray($i,"neighbor") diff --git a/lexilla/test/examples/tcl/x.tcl.styled b/lexilla/test/examples/tcl/x.tcl.styled new file mode 100644 index 000000000..66af41327 --- /dev/null +++ b/lexilla/test/examples/tcl/x.tcl.styled @@ -0,0 +1,13 @@ +{2}# tcl tests +{0} +{2}#simple example +{0} +{12}proc{0} {7}Echo_Server{0} {6}{{7}port{6}}{0} {6}{ +{0} {12}set{0} {7}s{0} {6}[{12}socket{0} {10}-server{0} {7}EchoAccept{0} {8}$port{6}] +{0} {12}vwait{0} {7}forever{0}; +{6}} +{0} +{2}# Bug #1947 +{0} +{8}$s{6}({8}$i{6},{5}"n"{6}) +{12}set{0} {7}n{0} {8}$showArray{6}({8}$i{6},{5}"neighbor"{6}) diff --git a/lexilla/test/examples/vb/SciTE.properties b/lexilla/test/examples/vb/SciTE.properties new file mode 100644 index 000000000..54fead3f1 --- /dev/null +++ b/lexilla/test/examples/vb/SciTE.properties @@ -0,0 +1,2 @@ +lexer.*.vb=vb +keywords.*.vb=as dim or string diff --git a/lexilla/test/examples/vb/x.vb b/lexilla/test/examples/vb/x.vb new file mode 100644 index 000000000..a672831a0 --- /dev/null +++ b/lexilla/test/examples/vb/x.vb @@ -0,0 +1,13 @@ +' String" +Dim a As String = "hello, world" +Dim b As String = "hello world" +Dim c As String = "Joe said ""Hello"" to me" +Dim d As String = "\\\\server\\share\\file.txt" +' Character +""C "c"C "cc"C +' Date +d = #5/31/1993# or # 01/01/0001 12:00:00AM # +' Number +123_456___789 +123_ +&b10101_01010 diff --git a/lexilla/test/examples/vb/x.vb.styled b/lexilla/test/examples/vb/x.vb.styled new file mode 100644 index 000000000..1d19c8ae8 --- /dev/null +++ b/lexilla/test/examples/vb/x.vb.styled @@ -0,0 +1,13 @@ +{1}' String" +{3}Dim{0} {7}a{0} {3}As{0} {3}String{0} {6}={0} {4}"hello, world"{0} +{3}Dim{0} {7}b{0} {3}As{0} {3}String{0} {6}={0} {4}"hello world"{0} +{3}Dim{0} {7}c{0} {3}As{0} {3}String{0} {6}={0} {4}"Joe said ""Hello"" to me"{0} +{3}Dim{0} {7}d{0} {3}As{0} {3}String{0} {6}={0} {4}"\\\\server\\share\\file.txt"{0} +{1}' Character +{4}""C{0} {4}"c"C{0} {4}"cc"C{0} +{1}' Date +{7}d{0} {6}={0} {8}#5/31/1993#{0} {3}or{0} {8}# 01/01/0001 12:00:00AM #{0} +{1}' Number +{2}123_456___789{0} +{2}123_{0} +{2}&b10101_01010{0} |