diff options
| -rw-r--r-- | Changelog.md | 15 | ||||
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | src/ast.c | 9 | ||||
| -rw-r--r-- | src/ast.h | 2 | ||||
| -rw-r--r-- | src/inpla.y | 54 |
5 files changed, 68 insertions, 14 deletions
diff --git a/Changelog.md b/Changelog.md index 81d2998..57b90c8 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,20 @@ # Change log +### v0.10.4 (released on 28 January 2023) + +#### Bug fix + +- **A reuse annotation with the abbreviation `<<`**: The abbreviation `<<` could not be parsed with a reuse annotation. It is now fixed, and we can write it as follows: + + ``` + foo(r) >< (int n) + | n == 0 => r~n + | _ => r << (*L)foo(n-1); + // ^ The (*L) setting caused a parse error in a previous version. + ``` + + + ### v0.10.3 quite minor update (released on 12 January 2023) #### Minor bug fix @@ -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.3 (quite minor update), released on **12 January 2023**. (See [Changelog.md](Changelog.md) for details.) +* The current version is 0.10.4 (a bug fix), released on **28 January 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.  @@ -309,7 +309,7 @@ void ast_puts(Ast *p) { } -Ast *ast_unfoldABR(Ast *left_params, char *sym, Ast *paramlist) { +Ast *ast_unfoldABR(Ast *left_params, char *sym, Ast *paramlist, Ast *annotate) { // input: // left_params << (AST_AGENT, sym, paramlist) @@ -384,8 +384,13 @@ Ast *ast_unfoldABR(Ast *left_params, char *sym, Ast *paramlist) { } // ast_puts(left);puts(""); - + Ast *agent_left = ast_makeAST(AST_AGENT, ast_makeSymbol(sym), left_params); + if (annotate != NULL) { + // replace (AST_ANNOTATE NULL NULL) with (AST_ANNOTATE agent_left NULL) + annotate->left = agent_left; + agent_left = annotate; + } Ast *agent_right = param; Ast *cnct = ast_makeAST(AST_CNCT, agent_left, agent_right); @@ -53,7 +53,7 @@ void ast_puts(Ast *p); Ast *ast_paramToCons(Ast *ast); int ast_recordConst(char *name, int val); Ast *ast_remove_tuple1(Ast *p); -Ast *ast_unfoldABR(Ast *left_params, char *sym, Ast *paramlist); +Ast *ast_unfoldABR(Ast *left_params, char *sym, Ast *paramlist, Ast *annotate); int ast_getRecordedVal(int entry); #define ast_makeCons(x1,x2) ast_makeAST(AST_LIST,x1,x2) diff --git a/src/inpla.y b/src/inpla.y index 161bd33..e396a79 100644 --- a/src/inpla.y +++ b/src/inpla.y @@ -22,8 +22,8 @@ // ---------------------------------------------- -#define VERSION "0.10.3" -#define BUILT_DATE "12 January 2023" +#define VERSION "0.10.4" +#define BUILT_DATE "28 January 2023" // ------------------------------------------------------------------ @@ -184,6 +184,9 @@ agent_percent bodyguard bd_else bd_elif bd_compound if_sentence if_compound name_params +abr_annotate + +%type <chval> abr_agent_name //body %nonassoc REDUCE @@ -471,17 +474,34 @@ astparams ap : astterm CNCT astterm { $$ = ast_makeAST(AST_CNCT, $1, $3); } // -| astparams ABR AGENT LP astparams RP -{ $$ = ast_unfoldABR($1, $3, $5); } -| ABR AGENT LP astparams RP -{ $$ = ast_unfoldABR(NULL, $2, $4); } +// param << A(...) +| astparams ABR abr_agent_name LP astparams RP +{ $$ = ast_unfoldABR($1, $3, $5, NULL); } +// << A(...) +| ABR abr_agent_name LP astparams RP +{ $$ = ast_unfoldABR(NULL, $2, $4, NULL); } +// param << (*L)A(...) +| astparams ABR abr_annotate abr_agent_name LP astparams RP +{ $$ = ast_unfoldABR($1, $4, $6, $3); } +// << (*L)A(...) +| ABR abr_annotate abr_agent_name LP astparams RP +{ $$ = ast_unfoldABR(NULL, $3, $5, $2); } // -| astparams ABR NAME LP astparams RP -{ $$ = ast_unfoldABR($1, $3, $5); } -| ABR NAME LP astparams RP -{ $$ = ast_unfoldABR(NULL, $2, $4); } +//| astparams ABR NAME LP astparams RP +//{ $$ = ast_unfoldABR($1, $3, $5, NULL); } +//| ABR NAME LP astparams RP +//{ $$ = ast_unfoldABR(NULL, $2, $4, NULL); } ; +abr_agent_name +: AGENT { $$ = $1; } +| NAME { $$ = $1; } +; + +abr_annotate +: LP ANNOTATE_L RP { $$ = ast_makeAST(AST_ANNOTATION_L, NULL, NULL); } +| LP ANNOTATE_R RP { $$ = ast_makeAST(AST_ANNOTATION_R, NULL, NULL); } +; aplist @@ -10836,6 +10856,20 @@ int exec(Ast *at) { // Syntax error check { Ast *tmp_at=at; + + if (Ast_eqs_has_agentID(tmp_at, AST_ANNOTATION_L)) { + puts("Error: Given nets contain `(*L)'."); + // invalid case + if (yyin != stdin) exit(-1); + return 0; + } + if (Ast_eqs_has_agentID(tmp_at, AST_ANNOTATION_R)) { + puts("Error: Given nets contain `(*R)'."); + // invalid case + if (yyin != stdin) exit(-1); + return 0; + } + while (tmp_at != NULL) { if (!(check_ast_arity(tmp_at->left->left)) |
