-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Support compile_string passing parsing state #7462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support compile_string passing parsing state #7462
Conversation
I think the feature is reasonable, but I really don't like having a global flag control this. Can we make it a function argument instead? |
c931840
to
2867959
Compare
Maybe we should call the parameter skip_end_of_file (or begin_initial) instead of skip_initial? |
I wonder whether it would make sense to accept the starting state (as unsigned to avoid include)? That way you could start at yycST_IN_SCRIPTING, yycINITIAL or yycSHEBANG. This leaks internal details a bit though. |
I think this is a good suggestion, and it will facilitate further extensions of this function. Maybe someone really needs to start in another state. |
f7556db
to
8b26bb1
Compare
Whether |
d621ffc
to
668fd57
Compare
I'm not sure if this revision is good.
I have a requirement to execute encrypted PHP code.
Currently, I read the encrypted code into memory, then decrypt it, and write the decrypted content to a temporary file. Then call compile_file to fetch op_array.
Perhaps we can fetch op_array directly from compile_string. But it will report the problem:
Parse error: syntax error, unexpected token "<", expecting end of file
So, I need to remove T_OPEN_TAG myself. So I think it's fine if compile_string can skip T_OPEN_TAG.