In perl.git, the branch sprout/lexsub has been created <http://perl5.git.perl.org/perl.git/commitdiff/94808b5c4d40057184e1da2a753bc9bfd6c36d8c?hp=0000000000000000000000000000000000000000>
at 94808b5c4d40057184e1da2a753bc9bfd6c36d8c (commit) - Log ----------------------------------------------------------------- commit 94808b5c4d40057184e1da2a753bc9bfd6c36d8c Author: Father Chrysostomos <spr...@cpan.org> Date: Wed Jul 4 23:18:32 2012 -0700 Let barewords lookup our subs These take precedence over built-in keywords (just as my $AUTOLOAD shadows the package var), but not the keyword plugin, as the latter takes precedence over labels, and these donât. M t/cmd/lexsub.t M toke.c commit bcc3eb19a6a934b04aa13a0f30661e8ca8a2a637 Author: Father Chrysostomos <spr...@cpan.org> Date: Wed Jul 4 14:09:46 2012 -0700 toke.c:yylex:KEY_sub can use PL_tokenbuf to begin with There is no need to allocate a separate âtmpbufâ and then copy it into PL_tokenbuf afterwards. M toke.c commit 923a62968af216ebe8f7dfa85d904070e0e944f3 Author: Father Chrysostomos <spr...@cpan.org> Date: Wed Jul 4 09:13:17 2012 -0700 Make âsub foo{}â respect âour fooâ This commit switches all sub definitions, whether with âourâ or not, to using S_force_ident_maybe_lex (formerly known as S_pending_ident). This means that an unqualified (no our/my/state or package prefix) âsub fooâ declaration does a pad lookup, just like $foo. It turns out that the vivification that I added to the then S_pending_ident for CVs was unnecessary and actually buggy. We *donât* want to autovivify GVs for CVs, because they might be con- stants or forward declarations, which are stored in a simpler form. I also had to change the subname rule used by MYSUB in perly.y, since it can now be fed a PRIVATEREF, which it does not expect. This may prove to be temporary, but it keeps current tests passing. M perly.act M perly.h M perly.tab M perly.y M t/cmd/lexsub.t M toke.c commit d4e6a454623cb16484831c818d4cd2b68ac63434 Author: Father Chrysostomos <spr...@cpan.org> Date: Wed Jul 4 06:23:16 2012 -0700 Test initial tick in sub declaration M t/comp/parser.t commit f8eda8128a10aa4c9dff7c4e132316541c50fc13 Author: Father Chrysostomos <spr...@cpan.org> Date: Wed Jul 4 00:17:55 2012 -0700 Fix our sub with proto yylex must emit exactly one token each time it is called. Some- times yylex needs to parse several tokens at once. Thatâs what the various force functions are for. But that is also what PL_pending_ident is for. The various force_next, force_word, force_ident, etc., functions keep a stack of tokens (PL_nextval/PL_nexttype) that yylex will check imme- diately when called. PL_pending_ident is used to track a single identifier that yylex will hand off to S_pending_ident to handle. S_pending_ident is the only piece of code for resolving an identi- fier that could be lexical but could also be a package variable. force_ident assumes it is looking for a package variable. force_* takes precedence over PL_pending_ident. All this means that, if an identifier needs to be looked up in the pad on the next yylex invocation, it has to use PL_pending_ident, and the force_* functions cannot be used at the same time. Not realising that, when I made âour sub fooâ store the sub in the pad I also made âour sub foo ($)â into a syntax error, because it was being parsed as âour sub ($) fooâ (the prototype being âforcedâ); i.e., the pending tokens were being pulled out of the âqueueâ in the wrong order. (I put queue in quotes, because one queue and one unre- lated buffer together donât exactly count as âa queueâ.) Changing PL_pending_ident to have precedence over the force stack breaks ext/XS-APItest/t/swaptwostmts.t, because the statement-parsing interface does not localise PL_pending_ident. It could be changed to do that, but I donât think it is the right solution. Having two separate pending token mechanisms makes things need- lessly fragile. This commit eliminates the PL_pending_ident mechanism and modifies S_pending_ident (renaming it in the process to S_force_ident_maybe_lex) to work with the force mechanism. I was going to merge it with force_ident, but the two make incompatible assumptions that just complicate the code if merged. S_pending_ident needs the sigil in the same string buffer, to pass to the pad inter- face. force_ident needs to be able to work without a sigil present. So now we only have one queue for pending tokens and the order is more predictable. M embed.fnc M parser.h M proto.h M sv.c M t/cmd/lexsub.t M toke.c commit 78092bddcad0ecd4d0cb4653965e429d77d40e21 Author: Father Chrysostomos <spr...@cpan.org> Date: Mon Jul 2 21:26:13 2012 -0700 Make do sub() respect our declarations M t/cmd/lexsub.t M toke.c commit 001eb72264120554f0e178ae9e9bafdd608bdc8a Author: Father Chrysostomos <spr...@cpan.org> Date: Mon Jul 2 18:11:23 2012 -0700 do-file should not force a bareword A word following do is forced to be a bareword for do-subâs sake. But if it is going to be interpreted as do-file after all, that does not make sense. âdo subname;â should call the sub and run the file whose name it returns, instead of running the file named âsubnameâ. M t/op/do.t M toke.c commit 979c832a9e0ea1f7d7eec83ed01e7f6d1fb53bd0 Author: Father Chrysostomos <spr...@cpan.org> Date: Mon Jul 2 14:47:50 2012 -0700 Let do.t run from the top level M t/op/do.t commit c4c6e57dadb6e0b2d2fdb68b040a115e61162b07 Author: Father Chrysostomos <spr...@cpan.org> Date: Mon Jul 2 14:47:34 2012 -0700 do.t: Load test.pl at BEGIN time so that parentheses can be omitted. M t/op/do.t commit 9e715161e63def095d9ad2cd063faf58659c2779 Author: Father Chrysostomos <spr...@cpan.org> Date: Mon Jul 2 12:29:48 2012 -0700 lexsub.t: Fix a test This is not testing what I meant it to test: that âsub dâ will respect a preceding âour sub d;â. If âsub dâ is in the same package, it makes no difference, so the test tests nothing. It turns out this does not work yet. M t/cmd/lexsub.t commit 50488db2eba1275c422c32ea2e739086a12dca10 Author: Father Chrysostomos <spr...@cpan.org> Date: Mon Jul 2 09:07:31 2012 -0700 Use test.pl in lexsub.t I thought cmd/ couldnât use test.pl, but was mistaken. M t/cmd/lexsub.t commit dc51d6bb1a96fd4359bc701bac69269e69b8060e Author: Father Chrysostomos <spr...@cpan.org> Date: Sun Jul 1 23:05:21 2012 -0700 Allow test_bootstrap.t to run from the top level M t/cmd/lexsub.t M t/porting/test_bootstrap.t commit 01114d1db8188f7abf3ab5718c3eafc416298841 Author: Father Chrysostomos <spr...@cpan.org> Date: Sun Jul 1 22:53:41 2012 -0700 Make &foo respect our sub This changes &foo to go through S_pending_ident (by setting PL_pending_ident, which causes yylex to defer to S_pending_ident for the next token) the way $foo and %foo do. This necessitated reducing the maximum identifier length of &foo from 252 to 251, making it match @foo, $foo, etc. So somebodyâs JAPH might break. :-) M MANIFEST A t/cmd/lexsub.t M t/comp/parser.t M toke.c commit be836647134ab29f5d737173501150aa83cda6bf Author: Father Chrysostomos <spr...@cpan.org> Date: Sun Jul 1 20:23:06 2012 -0700 pad.c apidocs: Missing fullstop M pad.c commit deb4ce0dd608992ed8d9a8e34d442f7a233cc897 Author: Father Chrysostomos <spr...@cpan.org> Date: Sat Jun 30 23:20:25 2012 -0700 Allocate âour subâ in the pad Currently the name is only allocated there. Nothing fetches it yet. Notes on the implementation: S_pending_ident contains the logic for determining whether $foo or @foo refers to a lexical or package variable. yylex defers to S_pending_ident if PL_pending_ident is set. The KEY_sub case in yylex is changed to set PL_pending_ident instead of using force_word. For package variables (including our), S_pending_ident returns a WORD token, which is the same thing that force_word produces. So *that* aspect of this change does not affect the grammar. However.... The barestmt ruleâs SUB branch begins with âSUB startsub subnameâ. startsub is a null rule that creates a new sub in PL_compcv via start_subparse(). subname is defined in terms of WORD and also checks whether this is a special block, turning on CvSPECIAL(PL_compcv) if it is. That flag has to be visible during compilation of the sub. But for a lexical name, such as âour fooâ, to be allocated in the right pad, it has to come *before* startsub, i.e., âSUB subname startsubâ. But subname needs to modify the sub that startsub created, set- ting the flag. So I copied (not moved, because MYSUB still uses it) the name-checking code from the subname rule into the SUB branch of barestmt. Now that uses WORD directly instead of invoking subname. That allows the code there to set everything up in the right order. M perly.act M perly.h M perly.tab M perly.y M toke.c commit 9749fd948574b5fa59e16fc0fe96f18782bb9ffa Author: Father Chrysostomos <spr...@cpan.org> Date: Sat Jun 30 23:00:57 2012 -0700 Increase $Opcode::VERSION to 1.24 M ext/Opcode/Opcode.pm commit 828dfe56f907adef77580d6f4111a862771c15f1 Author: Father Chrysostomos <spr...@cpan.org> Date: Sat Jun 30 23:00:11 2012 -0700 Add padcv to Opcode.pm M ext/Opcode/Opcode.pm commit 00c8ff76e98389968f07a3b58da51cc6af78acf9 Author: Father Chrysostomos <spr...@cpan.org> Date: Sat Jun 30 22:29:28 2012 -0700 padcv op type M opcode.h M opnames.h M pp.c M pp_proto.h M regen/opcodes commit 67df098a2a7a4ca545d4397190a71c6e43f1974f Author: Father Chrysostomos <spr...@cpan.org> Date: Sat Jun 30 17:31:32 2012 -0700 Donât allow name after our/state sub It was a mistake that this was ever allowed. M MANIFEST M pod/perldiag.pod M t/lib/croak/toke M toke.c commit 8efad6839285a41e0f211df4dbfea6b3f3e989b4 Author: Father Chrysostomos <spr...@cpan.org> Date: Sat Jun 30 17:17:39 2012 -0700 Test âMissing name in "my sub"â M MANIFEST A t/lib/croak/toke ----------------------------------------------------------------------- -- Perl5 Master Repository