diff options
author | Zefram <zefram@fysh.org> | 2010-10-13 21:48:49 +0100 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2010-10-21 05:52:57 -0700 |
commit | 8eaa0acf70f47cc5d3ed085b62e8d46cbc245651 (patch) | |
tree | edc0d68a0337b2dd2ead7f97324e5f304f65d4b3 /toke.c | |
parent | 805700c1a37c475915b7e2c565a2b4ac1dbe5a97 (diff) | |
download | perl-8eaa0acf70f47cc5d3ed085b62e8d46cbc245651.tar.gz |
add lex_start to the API
lex_start() is added to the API, marked experimental, and documented.
It also gains a flags parameter for foreseeable future use.
Diffstat (limited to 'toke.c')
-rw-r--r-- | toke.c | 35 |
1 files changed, 24 insertions, 11 deletions
@@ -643,26 +643,39 @@ S_cr_textfilter(pTHX_ int idx, SV *sv, int maxlen) } #endif +/* +=for apidoc Amx|void|lex_start|SV *line|PerlIO *rsfp|U32 flags + +Creates and initialises a new lexer/parser state object, supplying +a context in which to lex and parse from a new source of Perl code. +A pointer to the new state object is placed in L</PL_parser>. An entry +is made on the save stack so that upon unwinding the new state object +will be destroyed and the former value of L</PL_parser> will be restored. +Nothing else need be done to clean up the parsing context. + +The code to be parsed comes from I<line> and I<rsfp>. I<line>, if +non-null, provides a string (in SV form) containing code to be parsed. +A copy of the string is made, so subsequent modification of I<line> +does not affect parsing. I<rsfp>, if non-null, provides an input stream +from which code will be read to be parsed. If both are non-null, the +code in I<line> comes first and must consist of complete lines of input, +and I<rsfp> supplies the remainder of the source. +The I<flags> parameter is reserved for future use, and must always +be zero. -/* - * Perl_lex_start - * - * Create a parser object and initialise its parser and lexer fields - * - * rsfp is the opened file handle to read from (if any), - * - * line holds any initial content already read from the file (or in - * the case of no file, such as an eval, the whole contents); - */ +=cut +*/ void -Perl_lex_start(pTHX_ SV *line, PerlIO *rsfp) +Perl_lex_start(pTHX_ SV *line, PerlIO *rsfp, U32 flags) { dVAR; const char *s = NULL; STRLEN len; yy_parser *parser, *oparser; + if (flags) + Perl_croak(aTHX_ "Lexing code internal error (%s)", "lex_start"); /* create and initialise a parser */ |