[phc-general] Changes in Abstract Grammar
peter5001 at gmx.de
Mon Oct 18 19:23:55 IST 2010
i am a web developer using php on a regular basis. but i must admit that
i do not know much about the inner working of compilers. i think phc is
a great project and i hope this is the right place for my question ;-)
i would like to add some experimental constructs to the grammar of php
(something like properties in c# or vala). so i wondered if this would
be possible with phc.
my idea is to use phc to transform a php script with an extended grammar
of php into a php script with regular grammar, by replacing non-regular
constructs with generated code (i.e. by replacing c#/vala-like
properties with java-bean-like accessor methods and private fields).
so i sketched the following code transformation chain:
1] PHP Script (with extensions to the grammar, i.e. properties)
... transformation into an AST using phc ...
2] PHC-AST (with extensions to the grammar, i.e. properties)
... replacement of non-regular constructs with regular code using the
Tree_transorm API ...
3] PHC-AST (regular grammar, i.e. accessor methods & private fields)
... transformation into regular php script ...
4] PHP Script (regular grammar, i.e. accessor methods & private fields)
i had a look at the source code of phc but as i started to experiment
with some code in "/generated_src" i couldn't compile phc anymore.
touching these files yields to an "permission denied error".
as you can see i dont know much about c++, makefiles and stuff like
that. but i would like to learn more about these things if my idea above
could be realized at all. so here is the actual question:
would it be possible to extend the syntax/grammar of phc
(/generated_src/php_scanner.lex & /generated_src/ast.tea ???) in order
to make such transformations (properties -> accessor methods)?
if yes, could you give me some hints? how would you do this?
any help is much appreciated!
thank you very much!
sorry for my bad english,
More information about the phc-general