lisachenko / z-engine

:zap: PHP Engine Direct API
MIT License
448 stars 22 forks source link

Custom keywords #17

Closed aolko closed 4 years ago

aolko commented 4 years ago

Hi there, is it possible to (re)define keywords?

lisachenko commented 4 years ago

Hello! What do you mean by redefining keywords? :)

lisachenko commented 4 years ago

It should be possible to redefine opcodes somewhen, but I haven’t plans to implement this ASAP, because it is very dangerous.

aolko commented 4 years ago

let's say i want real modules, in order to do that i need to implement module keyword as well as some macros, is it possible with your package?

lisachenko commented 4 years ago

@aolko see my previous comment. It should be doable via zend_compile_file and zend_compile_string hooks, but this question is out of my current scope of investigation, because there are too many things to implement and make this library stable.

lisachenko commented 4 years ago

It is possible now to control the AST tree of original source code during compilation, so you could check for token with specific meaning and adjust tree if required.

aolko commented 4 years ago

how would i detect a usual construct (in normal languages): module "AModule" or import "AModule" and transform it into the usual php mess of namespace and includes?