aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Sato <shinnya.sato@gmail.com>2023-05-07 21:36:00 +0900
committerShinya Sato <shinnya.sato@gmail.com>2023-05-07 21:36:00 +0900
commit6b97d6abff5dcd5142bd3982b4ad60fdb7d0804c (patch)
tree3bda6cc2480f73518e436416fa811558902be397
parent9f65b32712aa79fbf26ff3a298877ea99a6740eb (diff)
downloadinpla-6b97d6abff5dcd5142bd3982b4ad60fdb7d0804c.tar.gz
inpla-6b97d6abff5dcd5142bd3982b4ad60fdb7d0804c.zip
v0.10.8-1
Diffstat (limited to '')
-rw-r--r--Changelog.md44
-rw-r--r--README.md2
-rw-r--r--src/inpla.y66
-rw-r--r--src/name_table.c8
4 files changed, 92 insertions, 28 deletions
diff --git a/Changelog.md b/Changelog.md
index aae567d..bb6f5fa 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -1,5 +1,49 @@
# Change log
+### v0.10.8-1 minor update (released on 7 May 2023)
+#### Bug fix
+- **Segmentation faults in rule definitions**: This was caused by a lack of linearity checking, which had been omitted for some experiments. Also, the compilation environment was updated for incomplete rule definitions. These are now fixed. Previously, the segmentation fault error was caused as follows:
+
+ ```
+ Inpla 0.10.8 : Interaction nets as a programming language [built: 29 April 2023]
+ >>> eps() >< S(x) => eps~x; // This should be the linearity error
+ >>> eps() >< S(x) => eps~x; // The `eps' is recognised as a global name
+ Segmentation fault
+ ```
+
+ Of course, it works now:
+
+ ```
+ Inpla 0.10.8-1 : Interaction nets as a programming language [built: 7 May 2023]
+ >>> eps() >< S(x) => eps~x;
+ ERROR: `eps' is referred not twice in the right-hand side of the rule:
+ eps >< S.
+ >>> eps() >< S(x) => eps()~x;
+ >>>
+ ```
+
+#### Polished
+
+- **Pretty printing of agents**: 0-arity agents whose names start with a lowercase letters are printed with round brackets like `eps()`.
+
+ ```
+ >>> (a,b,c) ~ (Z, S(Z), eps());
+ (1 interactions, 0.00 sec)
+ >>> ifce;
+ a b c
+
+ Connections:
+ a ->Z
+ b ->S(Z)
+ c ->eps() // Previously, it was `c ->eps'.
+
+ >>>
+ ```
+
+
+
+
+
### v0.10.8 (released on 29 April 2023)
#### Bug fix
- **Segmentation faults due to use of 4-tuples or built-in Eraser**: These are now resolved.
diff --git a/README.md b/README.md
index a6cbe5a..5d5a715 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@
Inpla is a multi-threaded parallel interpreter of interaction nets. Once you write programs for sequential execution, it works also in multi-threaded parallel execution. Each thread is managed on each CPU-core with POSIX-thread library.
-* The current version is 0.10.8, released on **29 April 2023**. (See [Changelog.md](Changelog.md) for details.)
+* The current version is 0.10.8-1, released on **7 May 2023**. (See [Changelog.md](Changelog.md) for details.)
* The below graph shows speed-up ratio to threads numbers for programs in the following benchmark table.
![speedup-ratio](pic/benchmark_reuse_v0.10.7.png)
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; i<arity; i++) {
puts_term(AGENT(ptr)->port[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<CmEnv.bindPtr; i++) {
if ((CmEnv.bind[i].type == NB_META_L) || (CmEnv.bind[i].type == NB_META_R)) {
if (CmEnv.bind[i].refnum != 1) { // Be just once!
- printf("ERROR: `%s' is referred not once in the right-hand side of the rule definition", CmEnv.bind[i].name);
+ printf("ERROR: `%s' is referred not once in the right-hand side ", CmEnv.bind[i].name);
return 0;
}
+ } else if (CmEnv.bind[i].type == NB_NAME) {
+ if (CmEnv.bind[i].refnum != 1) { // Be just once in the RHS.
+ printf("ERROR: `%s' is referred not twice in the right-hand side ", CmEnv.bind[i].name);
+ return 0;
+ }
}
}
@@ -7291,17 +7311,20 @@ int Compile_rule_mainbody_on_ast(Ast *mainbody) {
if (!Compile_body_on_ast(body)) return 0;
- Compile_gen_RET_for_rulebody();
-
- CmEnv_retrieve_MKGNAME();
-
-
- if (!CmEnv_check_meta_occur_once()) {
- printf("in the rule:\n %s >< %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;
}
diff --git a/src/name_table.c b/src/name_table.c
index 06ff955..efe1fe0 100644
--- a/src/name_table.c
+++ b/src/name_table.c
@@ -117,11 +117,10 @@ IDTYPE NameTable_get_set_id_with_IdTable_forAgent(char *key) {
int hash;
NameList *add;
-
hash = getHash(key);
if (NameHashTable[hash] == NULL) {
-
+
add = NameList_new();
add->name = key;
add->id = IdTable_new_agentid();
@@ -134,9 +133,8 @@ IDTYPE NameTable_get_set_id_with_IdTable_forAgent(char *key) {
NameList *at = NameHashTable[hash];
while (at != NULL) {
- if (strcmp(at->name, key) == 0) {
- return (at->id);
-
+ if (strcmp(at->name, key) == 0) {
+ return (at->id);
}
at = at->next;
}