forked from fglock/Perlito
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TODO-perlito5
334 lines (227 loc) · 9.47 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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
TODO list for Perlito5
* perlito5 command-line
* 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
alternately, check $^H for strictness - such that perl's own strict.pm just works
and ${^WARNING_BITS} for warnings
* Parser
-- attributes
http://perldoc.perl.org/attributes.html
-- create __DATA__
http://perldoc.perl.org/SelfLoader.html#The-__DATA__-token
-- compile-time eval() is not bound to the "program" environment, but to the "compiler" environment instead
see README-perlito5-js near "Compile-time / Run-time interleaving"
my $v;
BEGIN { $v = "123" }
use Module $v; # $v is not accessible at compile-time
-- parse the regexes
create an AST for regexes
-- prototypes (signatures)
http://perldoc.perl.org/perlsub.html#Prototypes
check that undeclared barewords give the right error
*foo = sub () { ... } # does prototype work here?
check signature in sort()
fix the prototype for 'stat(*)' (see t/test.pl in the perl test suite)
-- add "print", "printf", "say" special parsing - note this is related to indirect object notation
indirect object notation
http://lwn.net/Articles/451486/
http://www.modernperlbooks.com/mt/2009/08/the-problems-with-indirect-object-notation.html
http://shadow.cat/blog/matt-s-trout/indirect-but-still-fatal/
http://perlbuzz.com/mechanix/2008/02/the-perils-of-perl-5s-indirect.html
method Module $param;
new Class( arg => $value );
new Class::($args);
say $config->{output} "This is a diagnostic message!"; # indirect call
say {$config->{output}} "This is a diagnostic message!"; # say to filehandle
use Class;
sub Class {
warn 'Called Class sub not Class package';
'Class'
}
my $q = Class->new; # calls the Class sub above
my $s = new Class; # throws a 'Bareword found where operator expected' error
my $t = Class::->new # this works
my $u = new Class::; # this also works (even with sub main in the current package)
-- "namespace" parsing
tests: t5/01-perlito/26-syntax-namespace.t
$ perl -e ' { package X; sub print { CORE::print(">$_[1]<\n") } } my $x = bless {}, "X"; print $x "xxx" '
Not a GLOB reference at -e line 1.
$ perl -e ' { package X; sub printx { CORE::print(">$_[1]<\n") } } my $x = bless {}, "X"; printx $x "xxx" '
>xxx<
$ perl -MO=Deparse -e ' print X:: "xxx" '
print X 'xxx';
$ perl -e ' use strict; my $x = X::; print $x '
X
$ perl -e ' use strict; my $x = X; print $x '
Bareword "X" not allowed while "strict subs" in use
$ perl perlito5.pl -MO=Deparse -e ' ::X::x::y '
join("", ::{'main::X::'} x main::y);
$ perl -MO=Deparse -e ' ::X '
'???';
$ perl -MO=Deparse -e ' sub X {} ::X '
sub X { }
X;
$ perl -e ' $::X::::X = 3; print $main::X::::X ' # 3
$ perl -e ' $::X::::X = 3; print $main::main::X::::X ' # 3
$ perl -e ' $::X::::X = 3; print $main::X::main::X ' # empty
$ perl -e ' $::X::::X = 3; print $main::X::X ' # empty
$ perl -e ' $::X::::X = 3; print $::::X::::X ' # empty
-- strict and warnings: create options like 'subs', 'refs'
-- clean up:
the several "end_tables" in Expression.pm are duplicating the function of
$Precedence in Precedence.pm - Expression.pm should use $Precedence directly.
-- things that work in perlito5, but which are errors in 'perl'
quotes vs. hash lookups:
$ perl -e ' q}} '
# ok
$ perl -e ' $x{ q}} } '
Unmatched right curly bracket at -e line 1, at end of line
$ perl -e ' $x{ q]] } '
# ok
string interpolation with nested quotes of the same type:
$ perl -e ' " $x{"x"} " '
String found where operator expected at -e line 1, near "x"} ""
-- add tests for fixed bugs:
add tests for signatures: "empty" _ $ ;$
---
add test for "sub _" should be in package "main"
$ perl -MO=Deparse -e ' package X; sub _ { 123 } '
package X;
sub main::_ {
123;
}
---
add test for defined-or vs. m// (2012/9/25 Конрад Боровски <[email protected]>)
Note: fixed; see test t5/01-perlito/25-syntax-defined-or.t
$ perl perlito5.pl -Isrc5/lib -Cast-perl5 -e ' shift // 2 '
Number or Bareword found where operator expected
$ perl perlito5.pl -Isrc5/lib -Cast-perl5 -e ' shift / 2 '
Can't find string terminator '/' anywhere before EOF
---
add test for 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
-- "given" statement not implemented
-- "default" statement not implemented
-- check that \(@a) and \@a have different meanings
-- ${^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 "
-- bug: ' $$x [$y] '
emits as ${$x}->[$y];
* Javascript backend
-- check that \(@a) and \@a have different meanings
-- delete() in the middle of an array turns exists() off:
$ perl -e ' @a = (3..7); delete $a[2]; print "exists ", (exists $a[$_] ? 1 : 0), "\n" for 0 .. $#a '
exists 1
exists 1
exists 0
exists 1
exists 1
-- "or" has SCALAR context (Abigail++):
See: t5/01-perlito/23-eval.t
-- "~~" operator not implemented; See also "when" implementation
-- "given" statement not implemented
-- "when" should use a "break" exception inside "given", and a "next" exception inside "for".
-- "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
-- 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
-- references to typeglobs:
$ perl -e ' print ref(\*main) '
GLOB
-- aliasing between lexicals and globals
$ perl -e 'use strict; my $x = 3; *main::z = \$x; print $main::z; '
3
-- string increment and string ranges
See: p5str_inc()
-- finish "overload" implementation
-- pack(), unpack()
-- y()()
-- BEGIN{} should execute in the environment of the program under compilation
-- BEGIN/END that are defined inside blocks/closures need to run inside some pseudo-environment
even if the closure was never created or used in the first place
-- bug - method call context is disabled, because it breaks bootstrap.
in Runtime.pm:
function p5call(invocant, method, list, p5want) {
list.unshift(invocant);
p5want = 0; // TODO BUG - workaround for broken bootstrap
* 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