Skip to content

Commit

Permalink
Merge pull request #285 from lmntal/feature/issue-268
Browse files Browse the repository at this point in the history
added --show-laststep-only option
  • Loading branch information
UzawaSeishiro committed Mar 8, 2022
2 parents eebb784 + 6ff0b99 commit 1052925
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/env.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ LmnEnv::LmnEnv() {
this->output_format = DEFAULT;
this->mc_dump_format = CUI;
this->sp_dump_format = SP_NONE;
this->show_laststep_only = FALSE;
this->nd = FALSE;
this->ltl = FALSE;
this->ltl_all = FALSE;
Expand Down
2 changes: 2 additions & 0 deletions src/lmntal.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,8 @@ struct LmnEnv {
BOOL shuffle_rule;
BOOL shuffle_atom;

BOOL show_laststep_only;

enum OutputFormat output_format;
enum MCdumpFormat mc_dump_format;
enum SPdumpFormat sp_dump_format;
Expand Down
5 changes: 5 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ static void parse_options(int *optid, int argc, char *argv[]) {
{"dump-json", 0, 0, 1105},
{"dump-fsm-lmn-detail", 0, 0, 1106},
{"dump-fsm-hl", 0, 0, 1107},
{"show-laststep-only", 0, 0, 1108},
{"interactive", 0, 0, 1200},
{"translate", 0, 0, 1300},
{"hl", 0, 0, 1350},
Expand Down Expand Up @@ -332,6 +333,10 @@ static void parse_options(int *optid, int argc, char *argv[]) {
case 1107:
lmn_env.mc_dump_format = LMN_FSM_GRAPH_HL_NODE;
break;
case 1108:
lmn_env.trace = TRUE;
lmn_env.show_laststep_only = TRUE;
break;
case 1200: /* jni interactive mode */
#ifdef HAVE_JNI_H
lmn_env.interactive = TRUE;
Expand Down
17 changes: 12 additions & 5 deletions src/vm/task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,17 @@ void Task::lmn_run(Vector *start_rulesets) {
mrc->memstack_reconstruct(mem);

if (lmn_env.trace) {
if (lmn_env.output_format != JSON) {
if (lmn_env.show_laststep_only) {
mrc->increment_reaction_count();
fprintf(stdout, "%d: ", mrc->get_reaction_count());
} else {
if (lmn_env.output_format != JSON) {
mrc->increment_reaction_count();
fprintf(stdout, "%d: ", mrc->get_reaction_count());
}
lmn_dump_cell_stdout(mem);
if (lmn_env.show_hyperlink)
lmn_hyperlink_print(mem);
}
lmn_dump_cell_stdout(mem);
if (lmn_env.show_hyperlink)
lmn_hyperlink_print(mem);
}

mem_oriented_loop(mrc.get(), mem);
Expand All @@ -222,6 +226,7 @@ void Task::lmn_run(Vector *start_rulesets) {
if (lmn_env.sp_dump_format == LMN_SYNTAX) {
fprintf(stdout, "finish.\n");
} else {
if (lmn_env.show_laststep_only) fprintf(stdout, "%d: ", mrc->get_reaction_count());
lmn_dump_cell_stdout(mem);
}
}
Expand Down Expand Up @@ -411,6 +416,8 @@ BOOL Task::react_rule(LmnReactCxtRef rc, LmnMembraneRef mem, LmnRuleRef rule) {
rc->increment_reaction_count();
} else if (lmn_env.output_format == JSON) {
lmn_dump_cell_stdout(rc->get_global_root());
} else if (lmn_env.show_laststep_only) {
rc->increment_reaction_count();
} else {
fprintf(stdout, "---->%s\n", lmn_id_to_name(rule->name));
rc->increment_reaction_count();
Expand Down

0 comments on commit 1052925

Please sign in to comment.