This is only a draft... :)
I considered about this carefully, determined all important steps. Generally speaking it should be divided into several parts. All interpreters (and mine) need the stability in general, so first, a few steps :
Step 1 : Determine the language structure. An interpreter should have variables, functions and the world around. Create a class which stores a variable with its attributes and value. And the functions, create an array and use the "Linear search" method. Maybe I'll combine all various basic variable definitions into a single definition, such as "double", only double and double. Only a thing I'm afraid is the double is always calculated slower than other definitions. The vector is a great idea, but I doubt, the reason of speed. "A good thing that a vector can do" is unlimited variable size with lots of effective algorithms. So it can avoid almost of different crash errors (such as Access Violation). I'll delete some concept words, such as "inline", because it's not necessary. IMO calling a function is not easy, I have to make two types, the first one is the "local function" (or the "handmade function") which the debugger execute directly. The second one is calling other functions through Dlls (Dynamic-link-library). The simple language and grammar are really a perfect choice. I have no idea, and now I'm trying to think about new concepts. I'm not a professional programmer... :)
Step 2 : Building a compiler : A proper compiler for a specific source type is very necessary. And certainly, nowadays all compilers are very intelligent. A compiler compiles a source and submits the compiling results to a linker. But I have the another idea. In this case the compiler is not one of the most important tool (Negative??) The debugger still loads and runs any script source properly, even without a compiler. The compiler (can be called as "repairer") compiles the source the shows the user how many compiling errors (errors & warnings) are there in a specific source that an user specified. The additional feature is code optimization. The goal is making a source run faster without affecting the program results. Warnings and minor errors (can be repaired), only major errors (which and where the debugger will halt immediately) are showed completely. And certainly the debugger also is an intelligent compiler. The compiler is just a part of the debugger (or parser) product. The world of any primary programming language certainly is very large, however in case script language, the world is limited, and so it needs a primary language to work. That requires lots of times to add all necessary things. I'll generate a new address, then assign something. That only requires a code, then the parser, the compiler and the debugger will do all for you...
Long story short, a language should be clear, easy to read and understand. A clear language will make everything simpler more, you'll only need to build the structures and a loader, and pick a source that you want to execute...
And the next step? No obvious answers. And finally, consider again :
First : Code look & style - Second : Performance - Third : Efficiency.
Edit : And a question :
Simple code :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
int FunctionName(char *string){if(!string || !strlen(string))return -1;
int min = 0, max;
switch(string[0])
{
case 'a' : max = value;break;
case 'b' : min = value;max = value;break;
case 'c'....
}
for(int i = min;i <= max;i++)
if(!strcmp(string, funcName[i]))return i;
return -1;
}
| |
Is this a good idea? That uses two variables : min, and max. In short they will limit the search range and hence the program will run faster.
What do you think? Any idea? :)