-
Notifications
You must be signed in to change notification settings - Fork 47
/
TODO-perlito5
executable file
·231 lines (150 loc) · 6.07 KB
/
TODO-perlito5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
TODO list for Perlito5
* perlito5 command-line
-- search for modules in PERL5LIB
perlito5 own directories must be searched first (perlito5 defines it's own strict.pm)
maybe search PERLITO5LIB first
alternately, check $^H for strictness - such that perl's own strict.pm just works
and ${^WARNING_BITS} for warnings
* libraries
-- these should probably go into namespace Perlito5X::*
-- Test (implemented as Perlito5::Test)
-- Data::Dumper (implemented as Perlito5::Dumper)
-- create perlito5-specific libs for:
feature.pm
Config.pm
overload.pm
bytes.pm
integer.pm
constant.pm
lib.pm
Carp.pm
vars.pm
Tie::Array
Tie::Hash
Tie::Scalar
* Parser
-- create __DATA__
-- "sub _" should be in package "main"
-- "given" statement not implemented
-- "default" statement not implemented
-- clean up:
the several "end_tables" in Expression.pm are duplicating the function of
$Precedence in Precedence.pm - Expression.pm should use $Precedence directly.
-- bug: ' $$x [$y] '
parses as ${$x}->[$y];
-- ' 123 456 ' should be a syntax error (parses as two statements)
-- ' $# ' should be a syntax error (parses as $#{undef} )
-- ' $x->meth 123 ' should be a syntax error
-- fix the prototype for 'stat(*)' (see t/test.pl in the perl test suite)
-- compile-time eval() is not bound to the "program" environment, but to the "compiler" environment instead
my $v;
BEGIN { $v = "123" }
use Module $v; # $v is not accessible at compile-time
-- parse the regexes
-- prototypes (signatures)
--- done: "empty" _ $ ;$
--- check that undeclared barewords give the right error
--- *foo = sub () { ... } # does prototype work here?
--- check signature in sort()
-- check that \(@a) and \@a have different meanings
-- parse "local $x[1]"
-- parse local $@
-- $v{x::y} autoquotes the index when x::y() exists
-- $v->{x} doesn't interpolate inside double quotes
-- deref inside double quotes:
$ node perlito5.js -Bjs -e ' my $x = "123"; my $y = \$x; print "[$$y]\n" '
[$[object Object]]
-- add "print" special parsing - note this is related to indirect object notation
-- indirect object notation
method Module $param;
-- lookup for existing subroutines:
sub m { my @x = 8, 9; @x } $x = m(); # m() is not a "match"
-- add tests for fixed bugs:
filetest operators special case:
' -f($file).".bak" ' should be equivalent to -f "$file.bak"
parses as -(f($file)).".bak"
but: ' -f ($file).".bak" '
parses correctly
This seems to be because there is a rule that \w followed by '(' is a function call;
this needs more testing: ' ... and(2) '
Test: redefine 'and', 'not' and check what works.
' $s111++ + $s222 '
parses as (+$s222)++
' $step++ < $steps '
Can't find string terminator '>' anywhere before EOF
* Perl5 backend
-- ${^NAME} needs curly-escaping
- fix regex delimiters, or escape the regexes
-- continue block in block: ' { print 1 } continue { print 2 } '
-- emitter bug: significant parenthesis:
t5/01-perlito/12-context.t fails because:
" return (4, 5) " instead of " return 4, 5 "
* Javascript backend
-- "~~" operator not implemented; See also "when" implementation
-- "when" should use a "break" exception inside "given", and a "next" exception inside "for".
-- "given" statement not implemented
-- "default" statement not implemented
-- bug: some declarations are not "seen":
for ( my $i = 0; $i < 10 ; $i++ ) { print "$i\n" } # compiles to global $i
-- bug: don't emit throw() in term position; javascript requires a function() wrapper because throw() is a statement
-- initialize @INC from $ENV{PERL5LIB}
-- javascript errors don't show in the global error handler when running in node.js
-- "autoload" the compiler if eval-string is used (eval-string needs the compiler at run-time)
-- symbol variables like $] ${"main::\$"} $#_
-- check that @_, $_, $a, $b and other special variables are in the right context (lexical, global, package global)
-- emit array/hash slices: @a[@x], @a{@x}
-- add alternate mro's
-- cache the mro
-- add regex compiler
-- /e modifier
-- /x modifier
-- support all perl5 regex syntax
-- @v = /x/g
-- bug: variable redeclaration does not work
-- javascript "var" erases the outer value within the whole current lexical scope
-- bug: "my" variables - this doesn't work as expected: my $v = $v
possible fix: rename variables
-- lvalue ternary: ($a_or_b ? $a : $b) = $c;
-- lvalue substr()
-- 4-arguments substr()
-- pos($str)
-- lvalue chomp(), chop()
-- missing some types of subroutine signatures
-- bug: variable aliases create copies instead
-- generate more compact code; maybe use more subroutines instead of inlining;
autovivification is probably the most verbose part of the code.
-- in the browser: implement "use" with XMLHttpRequest (what are the security implications?)
-- add symbol tables for scalar, array and hash
-- string increment and string ranges
See: p5str_inc()
-- finish "overload" implementation
-- pack(), unpack()
-- sprintf()
-- y()()
-- BEGIN{} should execute in the environment of the program under compilation
-- AUTOLOAD
AUTOLOAD is implemented for method lookups, but not for normal subroutines
* Nice to Have
-- debugging symbols
-- line numbers in error messages
-- caller()
-- "when"
-- run more of the "perl" test suite
-- proper "use strict" and "use warnings"
-- use the same error messages and warnings as 'perl'
-- no warnings 'redefine';
-- __LINE__, __FILE__
-- INIT{}, END{}
look at the implementation in perlito6-in-Go
-- source code - remove Perl 6 code such as "token"
(fixed: This is only loaded if the grammar compiler is needed)
-- *{ $name }{CODE}->();
-- local(*{$caller."::a"}) = \my $a;
-- *{$pkg . "::foo"} = \&bar;
* Deprecate
-- remove unused features from src5/lib/Perlito5/Grammar/Regex.pm
-- Interpreter backend
this is not being maintained; the code is still in src5/lib/Perlito5/Eval.pm just in case
-- Perl6 backend (started)
this is not being maintained; not sure if compiling to Perl6 is the best way
maybe compiling directly to Parrot/dotnet/Haskell gives better results