void parse_statement(int eval_flag) {
// parse a simple if/if-else statement
if (accept(TOKEN_IF)) {
// if is always followed by an expression and then a newline
test_result = to_boolean(parse_expression());
expect(TOKEN_EOL);
// parse if body
parse_block(eval_flag && test_result);
// if there's an else clause, parse it, but only execute if first block is false
if (accept(TOKEN_ELSE)) {
expect(TOKEN_EOL);
parse_block(eval_flag && !test_result);
}
// follow up with an end
expect(TOKEN_END);
expect(TOKEN_EOL);
// not an if-statment, must be a command
} else {
expect(TOKEN_IDENTIFIER, &name);
while (!accept(TOKEN_EOL))
argv[argc++] = parse_expression();
if (eval_flag)
execute_command(name, argv);
}
}
// parse a set of one or more statements
void parse_block(int eval_flag) {
while (!peek(TOKEN_ELSE) && !peek(TOKEN_END))
parse_statement(eval_flag);
}
// main body of script
void parse_main() {
while (!accept(TOKEN_EOF))
parse_statement(true);
}
struct mob_prog_token
{
NPC_TOKEN * next;
NPC_TOKEN * prev;
bool type;
char * string;
sh_int value; /* value of command/social table */
void * function; /* Which do_fun to use */
bool level; /* Nesting level */
};
You take the words right out of my mouth there. I know relatively more about Lua than anyone here knows about mrmud's mobprogs, so yes, you're so ignorant you can't really say anything sensible, other than 'hahahahahahaha'. Elanthis is so clueless it's not even funny. I'm starting to doubt that he actually saw the source code, though it's cute if he tried to look at it just to have an opinion, and even cuter that you echo his opinion, it's like watching the seven dwarves march in line.
Somehow I'm not surprised that part has you and elanthis stumped, but on the bright side, you can just hack in lua support which is a no brainer.