From 6b97d6abff5dcd5142bd3982b4ad60fdb7d0804c Mon Sep 17 00:00:00 2001 From: Shinya Sato Date: Sun, 7 May 2023 21:36:00 +0900 Subject: v0.10.8-1 --- src/inpla.y | 66 ++++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 22 deletions(-) (limited to 'src/inpla.y') diff --git a/src/inpla.y b/src/inpla.y index c0833c3..c15640d 100644 --- a/src/inpla.y +++ b/src/inpla.y @@ -22,8 +22,8 @@ // ---------------------------------------------- -#define VERSION "0.10.8" -#define BUILT_DATE "29 April 2023" +#define VERSION "0.10.8-1" +#define BUILT_DATE "7 May 2023" // ------------------------------------------------------------------ @@ -1633,21 +1633,36 @@ void puts_term(VALUE ptr) { } else { // Agent int i, arity; - + int with_parenthses = 1; + char *agent_name; + arity = IdTable_get_arity(AGENT(ptr)->basic.id); - printf("%s", IdTable_get_name(AGENT(ptr)->basic.id)); - if (arity != 0) { + agent_name = IdTable_get_name(AGENT(ptr)->basic.id); + printf("%s", agent_name); + + if (((agent_name[0] >= 'A') && (agent_name[0] <= 'Z')) + && (arity == 0)) { + // If the first letter of agent_name is not capital and the arity is 0 + // then parentheses is not needed. + with_parenthses = 0; + } + + + if (with_parenthses) { printf("("); } + for (i=0; iport[i]); if (i != arity - 1) { printf(","); } } - if (arity != 0) { + + if (with_parenthses) { printf(")"); } + } } @@ -3588,17 +3603,22 @@ int CmEnv_newvar(void) { -int CmEnv_check_meta_occur_once(void) { +int CmEnv_check_linearity_in_rule(void) { int i; for (i=0; i< %s.\n", + if (!CmEnv_check_linearity_in_rule()) { + printf("of the rule:\n %s >< %s.\n", IdTable_get_name(CmEnv.idL), IdTable_get_name(CmEnv.idR)); return 0; } + + + Compile_gen_RET_for_rulebody(); + + // Change MKNAME to MKGNAME if the name occurs just onece + CmEnv_retrieve_MKGNAME(); + + return 1; @@ -7752,6 +7775,7 @@ int get_ruleagentID(Ast *ruleAgent) { id = IdTable_getid_builtin_funcAgent(ruleAgent); if (id == -1) { id=NameTable_get_set_id_with_IdTable_forAgent(ruleAgent->left->sym); + } } @@ -7786,6 +7810,8 @@ int make_rule_oneway(Ast *ast) { start_timer(&t); #endif + CmEnv_clear_all(); + ruleAgent_L = ast->left->left; ruleAgent_R = ast->left->right; @@ -7823,7 +7849,6 @@ int make_rule_oneway(Ast *ast) { idL = get_ruleagentID(ruleAgent_L); } - /* // Annotation (*L)、(*R) の処理があるため // 単純に ruleAgentL、ruleAgentR を入れ替えれば良いわけではない。 @@ -7895,9 +7920,8 @@ int make_rule_oneway(Ast *ast) { gencode_num = 2; - - CmEnv_clear_all(); + // CmEnv_clear_all(); if (idL == ID_INT) { set_metaL_as_IntName(ruleAgent_L); @@ -7954,7 +7978,6 @@ int make_rule_oneway(Ast *ast) { if (!Compile_rule_mainbody_on_ast(rule_mainbody)) return 0; - #ifdef OPTIMISE_IMCODE_TCO if (is_tco) { @@ -7968,7 +7991,7 @@ int make_rule_oneway(Ast *ast) { #endif - // #define DEBUG_MKRULE + // #define DEBUG_MKRULE #ifndef DEBUG_MKRULE gencode_num += CmEnv_generate_VMCode(&code[2]); #else @@ -8005,7 +8028,6 @@ int make_rule_oneway(Ast *ast) { // ast_puts(ruleAgent_R); puts(""); #endif - // Record the rule code for idL >< idR RuleTable_record(idL, idR, code, gencode_num); @@ -8054,7 +8076,7 @@ int make_rule_oneway(Ast *ast) { IdTable_get_name(idR), (double)(time)/1000000.0); #endif - + return 1; } -- cgit v1.2.3