Inlined load
This commit is contained in:
parent
2250f9231e
commit
98748fb44d
25
src/modal.c
25
src/modal.c
|
@ -213,12 +213,17 @@ print_rules(void)
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
int
|
||||||
load(char *path)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
FILE *f;
|
||||||
char c, *w = bank_a;
|
char c, *w = bank_a;
|
||||||
FILE *f = fopen(path, "r");
|
if(argc < 2)
|
||||||
if(!f) return 0;
|
return !printf("usage: modal [-v] source.modal\n");
|
||||||
|
if(argc < 3 && argv[1][0] == '-' && argv[1][1] == 'v')
|
||||||
|
return !printf("Modal - Modal Interpreter, 4 Apr 2024.\n");
|
||||||
|
if(!(f = fopen(argv[1], "r")))
|
||||||
|
return !printf("Invalid Modal file: %s.\n", argv[1]);
|
||||||
while(fread(&c, 1, 1, f)) {
|
while(fread(&c, 1, 1, f)) {
|
||||||
if(prog_ > bank_a) {
|
if(prog_ > bank_a) {
|
||||||
if(c == ')' && *(w - 1) == ' ') w--;
|
if(c == ')' && *(w - 1) == ' ') w--;
|
||||||
|
@ -231,18 +236,6 @@ load(char *path)
|
||||||
}
|
}
|
||||||
*w++ = 0;
|
*w++ = 0;
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
if(argc < 2)
|
|
||||||
return !printf("usage: modal [-v] source.modal\n");
|
|
||||||
if(argc < 3 && argv[1][0] == '-' && argv[1][1] == 'v')
|
|
||||||
return !printf("Modal - Modal Interpreter, 4 Apr 2024.\n");
|
|
||||||
if(!load(argv[1]))
|
|
||||||
return !printf("Invalid Modal file: %s.\n", argv[1]);
|
|
||||||
queue = 2;
|
queue = 2;
|
||||||
while(rewrite(argv[queue]))
|
while(rewrite(argv[queue]))
|
||||||
;
|
;
|
||||||
|
|
Loading…
Reference in New Issue