/** * Translates a program from one human language to another. */ void ctr_translate_program(char* prg, char* programPath) { ctr_dict* dictionary; int t; char* p; dictionary = ctr_translate_load_dictionary(); ctr_clex_set_ignore_modes(1); ctr_clex_load(prg); t = ctr_clex_tok(); p = prg; while ( 1 ) { if ( t == CTR_TOKEN_FIN ) { ctr_translate_fin(p); break; } else if ( t == CTR_TOKEN_QUOTE ) { p = ctr_translate_string(p, dictionary); } else if ( t == CTR_TOKEN_REF || t == CTR_TOKEN_BOOLEANYES || t == CTR_TOKEN_BOOLEANNO || t == CTR_TOKEN_NIL ) { p = ctr_translate_ref(p,dictionary); } else { p = ctr_translate_rest(p); } t = ctr_clex_tok(); } ctr_translate_unload_dictionary( dictionary ); }
/** * CTRParserStart * * Begins the parsing stage of a program. */ ctr_tnode * ctr_cparse_parse (char *prg, char *pathString) { ctr_tnode *program; ctr_clex_load (prg); char *oldp = ctr_cparse_current_program; ctr_cparse_current_program = pathString; program = ctr_cparse_program (); program->value = pathString; program->vlen = strlen (pathString); program->type = CTR_AST_NODE_PROGRAM; ctr_cparse_current_program = oldp; return program; }
/** * CTRParserStart * * Begins the parsing stage of a program. */ ctr_tnode* ctr_dparse_parse(char* prg) { ctr_tnode* program; ctr_clex_load(prg); program = ctr_cparse_program(); return program; }