I have an instruction format:
expr arg1 arg2 arg3...;
And if the expression was parsed correctly, they should be in reverse polish notation on the stack. Thus the execution stub should be something like:
int ExprCommand(int *argc,void * args[]){
while(args[argc]) {
sum = ExecBinary(acc,argds[argc]); // execute the individual op or compound condition
(*argc)++;
}
}
Simple stuff, made possible because efficiency is not the goal, simplified code is the goal. Because the shell uses a standard object format, linux command syntax, we can always swap out one script syntax for another. The linux command syntax thus becoming the de facto object format for shell scripters, better layering and integration with linux utilities.
All the unique cmd sequences not identified as part of script syntax will naturally fall through and be delivered to the sub systems to catch, as a cmd sequence. All I need, therefore, is ExprCommand and WhileCommand. Gets me everything I need for testing join.
The key insight, I keep repeating, is that we all already agree on an executable format for scripts, the linux cmd sequence. Easy to generate those on the fly. The ad hoc cmds from various developers all involve significant processing, that is the main goal to organize the significant processing of the commands. So parsing out our shell syntax as linux commands is not imposing undue inefficiency.
The other advantage, the syntax executables are just another subsystem from the shell command loop, very little effect and the loop can even load the syntax library at run time, like any other subsystem that use the (argc,args) call format, it will be compatible with the opaque shell.
Environmental variables are easier to set:
int Version = 30;
char * Script = "C Language";
The "CastCommand" will handle all declarations. So, a symbol table, a Cast, While and Expr command give me all I need. I just need the parser to grab the tokens and get them mostly in the right order in the arg list. The symbol table is an index over variables in the source and includes a type identifies. Cast is an easy to write command since I only need int and string types.
No comments:
Post a Comment