From c199aa618bcffe8a471bbe3e97f5787f6f0ce8ce Mon Sep 17 00:00:00 2001 From: Pentium44 Date: Tue, 18 May 2021 23:02:25 -0700 Subject: [PATCH] Working on it --- docs/README.txt | 20 +++++++++++------- src/lexer.c | 55 ++++++++++++++++++++++++------------------------- 2 files changed, 39 insertions(+), 36 deletions(-) diff --git a/docs/README.txt b/docs/README.txt index 313fb5f..b1efb08 100644 --- a/docs/README.txt +++ b/docs/README.txt @@ -37,7 +37,7 @@ at this moment! * cat "file.txt" "Data to write to end of file.txt" * Basic math expressions - * calc "45 / 5"` or `calc "255.3 * 442.77" + * calc "45 / 5" or calc "255.3 * 442.77" * Of course addition and subtraction as well * Time example: @@ -48,8 +48,8 @@ at this moment! * isfile "examples/functions.ss" -> returns 1, its there * File manipulation functions - * move "file1" "file2" -> Renames/moves file1 to file2 (mv) - * chdir "/home/user" -> Changes directory to /home/user (cd) + * move "file1" "file2" -> Renames/moves file1 to file2 (mv alias) + * chdir "/home/user" -> Changes directory to /home/user (cd alias) * backdir -> Moves you back one directory (..) * showpath -> Returns current working directory (pwd alias) * showdir -> Lists current directory (ls alias) @@ -62,8 +62,8 @@ at this moment! * exec "ls -al" (alias to ~"ls -al") * Slidescript compression functions, example: - * compress "archivename" "file1 file2 dir1 dir2" -> file1, 2, dir1, 2 archived, compressed, - and saved in in 'archivename.tar.ss' + * compress "archivename" "file1 file2 dir1 dir2" -> file1, 2, and dir1, 2 archived, compressed, + and saved in 'archivename.tar.ss' * decompress "archivename.tar.ss" -> decompresses 'archivename.tar.ss' * Print example: @@ -89,7 +89,7 @@ at this moment! * md5 "file.txt" -> outputs filename and md5 hash * Layered piping - * md5 "file.txt" | encrypt "%PIPE" | write "file.txt.md5.enc" "%PIPE%" -> writes output of md5 to file.txt.md5 + * md5 "file.txt" | encrypt "%PIPE%" | write "file.txt.md5.enc" "%PIPE%" -> writes output of md5 to file.txt.md5 * Networking functions * netlisten "" "" "" -> listens on and replies on found from outside @@ -119,9 +119,12 @@ This section will obviously expand and adapt to the direction of the language. T * Add in-script functions * Add script including -* Loops, and if statements * More networking function flexibility -* File pull / file push functionality +* File pull / file push functionality (via network sockets) +* Micro text editor +* IRC server, bot, and client built in +* Web server additions (pulled from chttpd) +* PATH variable support for use as a shell in some cases ----- Done @@ -140,6 +143,7 @@ List of finished features, in a rough summary. * Some simple functions * Shebang handling * Variable support +* If, ifn, loop, and comp statements ----- Changelog diff --git a/src/lexer.c b/src/lexer.c index df03dfc..1013cdb 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -71,7 +71,7 @@ char *process_line(char *line) if(tok_srch == NULL) { - x_warn("ss:warn:loop statement requires arguments"); + x_warn("ss:warn:if statement requires arguments"); return NULL; } @@ -80,7 +80,7 @@ char *process_line(char *line) strcmp(tok_srch, " \n") == 0 || strcmp(tok_srch, " ") == 0) { - x_warn("ss:warn:loop syntax error, missing argument?"); + x_warn("ss:warn:if syntax error, missing argument?"); return NULL; } @@ -91,7 +91,7 @@ char *process_line(char *line) tok_srch = strtok(NULL, ";"); if(tok_srch == NULL) { - x_warn("ss:warn:loop syntax error, missing last argument?"); + x_warn("ss:warn:if syntax error, missing last argument?"); return NULL; } @@ -115,11 +115,11 @@ char *process_line(char *line) char *dobuf; // We have an if statement - tok_srch = strtok(NULL, ";"); + tok_srch = strtok(NULL, ";"); if(tok_srch == NULL) { - x_warn("ss:warn:loop statement requires arguments"); + x_warn("ss:warn:ifn statement requires a compare argument."); return NULL; } @@ -128,30 +128,35 @@ char *process_line(char *line) strcmp(tok_srch, " \n") == 0 || strcmp(tok_srch, " ") == 0) { - x_warn("ss:warn:loop syntax error, missing argument?"); + x_warn("ss:warn:ifn syntax error, missing function call?"); return NULL; } - compbuf = qmalloc(QM_SS, (strlen(parse_vars(tok_srch)) + 1)); + compbuf = qmalloc(QM_SS, (strlen(tok_srch) + 1)); *compbuf = '\0'; - strcat(compbuf, parse_vars(tok_srch)); + strcat(compbuf, tok_srch); + printf("toksrch: %s\n", tok_srch); tok_srch = strtok(NULL, ";"); - if(tok_srch == NULL) - { - x_warn("ss:warn:loop syntax error, missing last argument?"); - return NULL; - } + printf("toksrch: %s\n", tok_srch); - dobuf = qmalloc(QM_SS, (strlen(parse_vars(tok_srch)) + 1)); - *dobuf = '\0'; - strcat(dobuf, parse_vars(tok_srch)); - - if((strncmp("false", compbuf, 4) == 0) || (strncmp("0", compbuf, 1) == 0)) + if( (strncmp("false", parse_vars(parse_bq(compbuf)), 5) == 0) + || (strncmp("0", parse_vars(parse_bq(compbuf)), 1) == 0)) { - proc_return = process_line(parse_vars(dobuf)); - printf("%s\n", proc_return); - fflush(stdout); + while(tok_srch != NULL) + { + dobuf = qmalloc(QM_SS, (strlen(tok_srch) + 1)); + *dobuf = '\0'; + strcat(dobuf, tok_srch); + + //proc_return = process_line(parse_vars(dobuf)); + //if(proc_return != NULL) { + // printf("%s\n", proc_return); + // fflush(stdout); + //} + printf("toksrch: %s\n", tok_srch); + tok_srch = strtok(NULL, ";"); + } } return NULL; @@ -445,7 +450,7 @@ char *process_line(char *line) retbuf = qmalloc(QM_SS, dirstr_size); - sprintf(retbuf, "%s\n", "ss:showdir:"); + sprintf(retbuf, "%s", ""); for (int ii = 0; ii < nn; ii++) { @@ -820,12 +825,6 @@ char *process_line(char *line) parsed = parse_vars(tok_srch); if(parsed != NULL) { - if(strtok(NULL, "\"") == NULL) - { - x_warn("ss:warn:print syntax error, missing end quote?"); - return NULL; - } - return parsed; } else