Is it possible to stop the parser during file scan

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • flconseil@yahoo.fr

    Is it possible to stop the parser during file scan

    Hello,

    I am writing a tool to package several files into a single file. It is
    quite similar to the 'phar' PEAR package but with more features, as I
    want to connect it with an autoload mechanism. The problem I have today
    and it is the same in the PHAR package, is that I don't know how to
    restrict the PHP parser to the bootstrap code of the package file.

    I explain : As in the shar format, the idea is to put some bootstrap
    code first, and the rest of the data after it. The problem is that I
    don't want PHP to consider any '<?php' string appearing in the data as
    some PHP code during the initial phase. An example : if I have
    something like :

    <?php Bootrap code ?> ...Anything... <?php ... Anything...

    In this case, I want the 2nd '<?php' to be considered as data and I
    don't want the tokenizer to go and look inside this section before
    executing the bootstrap code. I have the possibility to replace any
    '<?' string by another one, say '</?' and then translate them when they
    are extracted, but it is not easy to do because it changes every file
    offsets ! And, of course, I reference the files through their offsets
    in the package file.

    And compressing the files is not the perfect solution because :

    1. I want the compression to be optional for each file in the archive
    (and also the compression method)
    2. and the result of the compression process can contain a '<?' string,
    which would automatically lead to a syntax error (with short tags
    enabled).

    I tried to put a chr(0) after my code but PHP doesn't care. If there is
    a string or something allowing to stop the tokenizer at a given point
    in a script, or if you have a smarter idea, please tell me.

    Thanks in advance.

    François

  • flconseil@yahoo.fr

    #2
    Re: Is it possible to stop the parser during file scan

    For the ones who can have the same question, I got the answer from
    Davey Shafik : It is done by the __halt_compiler () pseudo-function
    (http://us2.php.net/halt_compiler)

    Comment

    Working...