develooper Front page | perl.perl6.internals.api.parser | Postings from November 2000

The external interface for the parser piece

Thread Next
From:
Dan Sugalski
Date:
November 27, 2000 14:29
Subject:
The external interface for the parser piece
Message ID:
5.0.1.4.0.20001127170630.024481b0@24.8.96.48
While I'm not sure of the structure of the internals of the parsing piece 
of perl at the moment (and, unfortunately, language parsers aren't one of 
my strong points), I am reasonably certain of the interface we'll present 
to the rest of the world and the other pieces of perl. So... comments?

---------------

   int perl6_parse(PerlInterp *interp,
                   void *source,
                   int flags,
                   void *extra_pointer);

The first parameter is a pointer to a perl interpreter--this'll be used if 
any code needs to be executed, as well as being a repository for any 
variables that compiled code may set. (Standard stash stuff) The syntax 
tree the parser generates will also be embedded here. (One fewer parameter 
to deal with, and one fewer thing for an embedding program to track)

The second parameter is a pointer to the source to be compiled. This is 
generally a char pointer, but it may also be a FILE * or a pointer to a 
function that returns a char pointer.

The third parameter is the flags parameter, and it's optional. If omitted 
or set to PERL_CHAR_SOURCE, the second parameter is treated as a standard 
null-terminated string. If set to PERL_COUNTED_SOURCE, the second parameter 
is treated as if it points to a stream of bytes, where the first four are 
the length of the source to be read followed by the source. If set to 
PERL_FILE_SOURCE it's assumed to be a FILE *, while if set to 
PERL_GENERATED_SOURCE it's assumed to be a pointer to a function that 
returns a char pointer. If it's OR'd with PERL_UTF8_SOURCE then the stream 
is assumed to be in UTF-8 format instead of platform native.

The fourth parameter is only used if the flags are set to 
PERL_GENERATED_SOURCE, in which case it is passed back to the function 
whose pointer we got as parameter two.

					Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
dan@sidhe.org                         have teddy bears and even
                                      teddy bears get drunk


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About