diff --git a/README.md b/README.md index ba51462..f17536f 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ + specifically for saol, I wrote a preprocessor called ssp (standard SAOL preprocessor), it runs separately from the main interpreter, and has the following features: + `.link ... ` -- connecting third-party files + `.macro ` -- creates a macro named name, the next time it is encountered, expr will be substituted for it - + `.prog` -- end of the preprocessor command block and start of the program + + `.prog` -- end of the preprocessor command block and start of the program (in version 1.3 and higher it is not necessary) ### Template for using a preprocessor in a program ``` diff --git a/arr_lib.c b/arr_lib.c index 59826e7..f537157 100644 --- a/arr_lib.c +++ b/arr_lib.c @@ -1,4 +1,4 @@ -/* Saol interpreter library v1.2 31/12/2019 by Centrix */ +/* Saol interpreter library v1.3 02/01/2020 by Centrix */ #include #include @@ -18,7 +18,11 @@ int len = 25; int pred = 1; void ini(char *arg) { - if (isint(arg)) + if (!strcmp(arg, "il")) { + arr[pos] = end - start - 1; + return ; + } + else if (isint(arg)) arr[pos] = atoi(arg); else arr[pos] = arg[0]; diff --git a/ssp.c b/ssp.c index efd4c00..d3078e9 100644 --- a/ssp.c +++ b/ssp.c @@ -4,8 +4,8 @@ /* * ssp - standard saol preprocessor - * v1.2 - * 31/12/2019 + * v1.3 + * 02/01/2020 * by Centrix */ @@ -17,6 +17,7 @@ void macro(char *arg), link(char *arg), prog(char *arg), copy(char *arg); char macro_names[1024][256], macro_codes[1024][256]; int len = 3, code = 3, pos = 0; FILE *src, *dst; +int is_end = 0; int main(int argc, char *argv[]) { char line[1024], *tok = ""; @@ -30,6 +31,7 @@ int main(int argc, char *argv[]) { dst = fopen(argv[2], "w"); while (fgets(line, 1024, src) != NULL) { + code = 3; pos = 0; tok = ssp_tok(line, &pos); @@ -46,7 +48,7 @@ int main(int argc, char *argv[]) { fclose(src); fclose(dst); - return 0; + return is_end; } char *ssp_tok(char *str, int *pos) { @@ -108,6 +110,7 @@ void macro(char *arg) { sprintf(macro_codes[pos++], "%s", arg); state = 0; } + is_end++; } void link(char *arg) { @@ -130,6 +133,7 @@ void link(char *arg) { putc('\n', dst); fclose(from); + is_end++; } void prog(char *arg) {