int main(int argc, char** argv) { if(argc != 2) { return 1; } parser_t* parser = malloc(sizeof(parser_t)); if(!parser) { return 1; } int status = parser_init(parser, argv[1]); if(status == 1) { free(parser); return 1; } parser_next(parser); while(parser->status != EOF) { BTree* node = do_assignment(parser); printf("\n** pre order **\n"); preorder(node); printf("\n** end **\n"); printf("\n%lli\n", eval(node)); //generate_code(node); } parser_shutdown(parser); return 0; }
void options_set(integrit_t *it, int argc, char *argv[]) { char buf[BUFSIZ]; char *cp; char *equalsign; FILE *conf; parse_args(it, argc, argv); if (! (conf = fopen(it->conffile, "r")) ) DIE("opening conf file"); while (fgets(buf, BUFSIZ, conf)) { cp = buf; EATSPACE(cp); if (blank_or_comment(cp)) continue; else if (*cp == '=') do_rule(it, cp); else if ( (equalsign = strchr(cp, '=')) ) do_assignment(it, cp, equalsign); else do_rule(it, cp); } if (! it->knowndbname) die(__FUNCTION__, "Error: known database unspecified"); if (! it->currdbname) die(__FUNCTION__, "Error: current database unspecified"); if (! it->root) die(__FUNCTION__, "Error: root search directory unspecified"); }
int command (void) /***** command scan a command and interpret it. return, if the user wants to quit. *****/ { header *expr; int ret=c_none; quit=0; error=0; errorout=0; while(1) { scan_space(); if (*next) break; else next_line(); } if (*next==1) return ret; expr=scan_expression(); if (!expr) { newram=endlocal; return ret; } if (error) { newram=endlocal; print_error(next); next=input_line; input_line[0]=0; return ret; } if (expr==&commandheader) { newram=endlocal; return commandtype; } switch (expr->type) { case s_real : case s_complex : case s_matrix : case s_cmatrix : case s_imatrix : case s_string : case s_interval : if (*next!=';') give_out(expr); if (*next==',' || *next==';') next++; break; case s_reference : case s_submatrix : case s_csubmatrix : case s_isubmatrix : do_assignment(expr); break; default : break; } if (error) print_error(next); newram=endlocal; if (error) { next=input_line; input_line[0]=0; } return ret; }