Download the PHP package ffi/preprocessor without Composer
On this page you can find all versions of the php package ffi/preprocessor. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package preprocessor
C23 Preprocessor for PHP
This implementation of a C-preprocessor based on ISO/IEC 9899:2024 - N3220.
You can also use a PHP C parser to subsequently parse the source code into an AST after preprocessing.
Requirements
- PHP ^8.1
Installation
Library is available as a Composer repository and can be installed using the following command in the root of your project.
Usage
Preprocessor::process() expands the macros and executes the directives of a C source,
the result is a stringable Result.
Method process() accepts:
SplFileInfo- filestring- the source textresource- streamPhplrt\Contracts\Source\ReadableInterface- any other source object
Result
Besides the output, the result tells what the run has learned. Each getter reads the output to the end first, and the result can be read more than once.
Macros
The $pre->macros holds the macros every run starts with.
The
__DATE__and__TIME__are taken from a PSR-20 clock, the system one by default.
File System
Any #include and #embed search for files in the file system of the preprocessor,
$pre->files.
Diagnostics
Ane #error and #warning are reported to a listener. By default, an error
stops the run with DiagnosticException and a warning is skipped.
The ready listeners are:
ThrowingDiagnosticListener- throws errorsStreamDiagnosticListener- writes diagnostic into the streamLoggerDiagnosticListener- A PSR-3 loggerNullDiagnosticListener- does nothingCompoundListener- combines several into one
Directives
Every directive has a handler, $pre->directives holds them. Add a
directive of your own or replace a standard one.
The context gives the handler the macros, the file system, the diagnostic listener and the executor that preprocesses an included file.
Pragmas
#pragma once is executed, any other pragma is passed to the output. A pragma
is executed by a processor, add one to react to a pragma of your own.
Limitations
List of preprocessor limitations. May be added to in the future.
Directives
#lineis not supported,__FILE__and__LINE__always tell the real file and line.#embedhas no parameters (limit,prefix,suffix,if_empty), and__has_embedis not supported.#pragma oncerecognizes a file by its pathname, the same file included by different paths is not detected.
Other Features
_Pragmaoperator is not supported.__VA_OPT__is not supported.__COUNTER__is not defined.__DATE__and__TIME__are taken from the clock at each replacement, not once per run.
All versions of preprocessor with dependencies
phplrt/exception Version ^4.2
phplrt/position Version ^4.2
phplrt/runtime Version ^4.2
psr/clock Version ^1.0
psr/log Version ^3.0