Display references in debug
This commit is contained in:
parent
42ab70b09d
commit
06c5c3c3da
12
src/modal.c
12
src/modal.c
|
@ -6,7 +6,7 @@ typedef struct {
|
||||||
} Rule;
|
} Rule;
|
||||||
|
|
||||||
static unsigned char rmin = 0xff, rmax = 0x00;
|
static unsigned char rmin = 0xff, rmax = 0x00;
|
||||||
static int flip, quiet, cycles = 0x10000;
|
static int flip, quiet, debug, cycles = 0x10000;
|
||||||
static Rule rules[0x1000], *rules_ = rules, lambda;
|
static Rule rules[0x1000], *rules_ = rules, lambda;
|
||||||
static char dict[0x8000], *dict_ = dict, empty;
|
static char dict[0x8000], *dict_ = dict, empty;
|
||||||
static char bank_a[0x4000], *src_ = bank_a;
|
static char bank_a[0x4000], *src_ = bank_a;
|
||||||
|
@ -247,8 +247,9 @@ main(int argc, char **argv)
|
||||||
return !printf("usage: modal [-vqn] source.modal\n");
|
return !printf("usage: modal [-vqn] source.modal\n");
|
||||||
for(i = 1; i < argc && *argv[i] == '-'; i++) {
|
for(i = 1; i < argc && *argv[i] == '-'; i++) {
|
||||||
switch(argv[i][1]) {
|
switch(argv[i][1]) {
|
||||||
case 'v': /* version */ return !printf("Modal Interpreter, 27 Apr 2024.\n");
|
case 'v': /* version */ return !printf("Modal Interpreter, 28 Apr 2024.\n");
|
||||||
case 'q': /* quiet */ quiet = 1; break;
|
case 'q': /* quiet */ quiet = 1; break;
|
||||||
|
case 'p': /* debug */ debug = 1; break;
|
||||||
case 'n': /* infinite */ cycles = 0xffffffff; break;
|
case 'n': /* infinite */ cycles = 0xffffffff; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -272,9 +273,12 @@ main(int argc, char **argv)
|
||||||
while(rewrite() && ++rw)
|
while(rewrite() && ++rw)
|
||||||
if(!cycles--) return !fprintf(stderr, "Modal rewrites exceeded.\n");
|
if(!cycles--) return !fprintf(stderr, "Modal rewrites exceeded.\n");
|
||||||
if(!quiet) {
|
if(!quiet) {
|
||||||
while(rules_-- > rules)
|
while(rules_-- > rules){
|
||||||
if(!rules_->refs && rules_->a)
|
if(!rules_->refs && rules_->a)
|
||||||
fprintf(stderr, "-- Unused rule: %d <> (%s) (%s)\n", rules_->refs, rules_->a, rules_->b);
|
fprintf(stderr, "-- Unused rule: %d <> (%s) (%s)\n", rules_->id, rules_->a, rules_->b);
|
||||||
|
if(debug && rules_->a)
|
||||||
|
fprintf(stderr, " (%s) (%s), %d times.\n", rules_->a, rules_->b, rules_->refs);
|
||||||
|
}
|
||||||
fprintf(stderr, ".. %s\nCompleted in %d rewrites.\n", src_, rw);
|
fprintf(stderr, ".. %s\nCompleted in %d rewrites.\n", src_, rw);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue