Mordred wrote:1. Why do you need this, what is the problem that you're trying to solve?
My goal with this is to allow my users to "program" components within my site. It was a thought I had to make things a bit more interesting for any developers/technically minded individuals that use my site.
The idea is that the user would be able to do something like:
Code: Select all
cvar comp1 = getComp(132);
cvar comp2 = getComp(145);
cvar combined = null;
if (isCompatible(comp1, comp2))
{ combined = combine(comp1, comp2); }
compile(combined);
That's obviously a very rough example... But that example would basically combine component 1 and component 2 to create a new component with the attributes and abilities of both components.
Mordred wrote:2. The easiest way to do this, is to make a tool that transforms your language to PHP
That's kind of what I'm trying to do, but, as far as I can tell, a tool like that would have to have some kind of grammatical parser which would indicate (for performance needs) that I need a lexer and parser to accomplish that task.
However, as I'm thinking, I suppose it would be possible to generate a list of methods within a standard php class and only allow those methods to be used. But again... I would have to parse the string (which could be huge) to insure that ONLY THOSE methods, functions, constants, etc... were being used which could be a slow and painful process. Though that might not be a terrible thing. It might add to the entertainment of this idea, giving the impression that these components are highly complex
I'm not sure... Maybe I'm thinking about this all wrong.