From 8eaa0acf70f47cc5d3ed085b62e8d46cbc245651 Mon Sep 17 00:00:00 2001 From: Zefram Date: Wed, 13 Oct 2010 21:48:49 +0100 Subject: 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. --- toke.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'toke.c') diff --git a/toke.c b/toke.c index 99aae57f3e..878547e1b9 100644 --- a/toke.c +++ b/toke.c @@ -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. 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 will be restored. +Nothing else need be done to clean up the parsing context. + +The code to be parsed comes from I and I. I, 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 +does not affect parsing. I, 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 comes first and must consist of complete lines of input, +and I supplies the remainder of the source. +The I 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 */ -- cgit v1.2.1