kinds of keyword-headed expression and compound statement. The syntax
following the keyword is defined entirely by the extension. This allow
a completely non-Perl sublanguage to be parsed inline, with the right
-ops cleanly generated.
-
-This feature is currently considered experimental, and using it to do
-anything interesting is difficult. Many necessary supporting facilities,
-such as the lexer and the pad system, can only be accessed through
-unsupported internal interfaces. It is intended that the Perl 5.13
-development cycle will see the addition of clean, supported interfaces
-for many of these functions. In Perl 5.12 most uses of pluggable keywords
-will be via L<Devel::Declare>.
+ops cleanly generated. This feature is currently considered experimental.
See L<perlapi/PL_keyword_plugin> for the mechanism. The Perl core source
distribution also includes a new module L<XS::APItest::KeywordRPN>, which
This module is mainly used for test purposes, and is not normally
installed, but also serves as an example of how to use the new mechanism.
+=head2 APIs for more internals
+
+The lowest layers of the lexer and parts of the pad system now have C
+APIs available to XS extensions. These are necessary to support proper
+use of pluggable keywords, but have other uses too. The new APIs are
+experimental, and only cover a small proportion of what would be necessary
+to take full advantage of the core's facilities in these areas. It is
+intended that the Perl 5.13 development cycle will see the addition of
+a full range of clean, supported interfaces.
+
=head2 Overridable function lookup
Where an extension module hooks the creation of rv2cv ops, to modify
} else if (filter_gets(linestr, old_bufend_pos)) {
got_some = 1;
} else {
+ if (!SvPOK(linestr)) /* can get undefined by filter_gets */
+ sv_setpvs(linestr, "");
eof:
/* End of real input. Close filehandle (unless it was STDIN),
* then add implicit termination.
register char *d;
STRLEN len;
bool bof = FALSE;
+ U32 fake_eof = 0;
/* orig_keyword, gvp, and gv are initialized here because
* jump to the label just_a_word_zero can bypass their
goto retry;
}
do {
- U32 fake_eof = 0;
+ fake_eof = 0;
+ bof = PL_rsfp ? TRUE : FALSE;
if (0) {
fake_eof:
fake_eof = LEX_FAKE_EOF;
s = PL_bufptr;
/* If it looks like the start of a BOM or raw UTF-16,
* check if it in fact is. */
- bof = PL_rsfp ? TRUE : FALSE;
- if (bof &&
+ if (bof && PL_rsfp &&
(*s == 0 ||
*(U8*)s == 0xEF ||
*(U8*)s >= 0xFE ||