Call this v0.2.1

master
Pentium44 2021-04-06 16:17:15 -07:00
parent 8356d6de8a
commit 8537c1acce
4 changed files with 48 additions and 4 deletions

View File

@ -1,7 +1,7 @@
# SlideScript makefile
# (C) Copyright 2014-2021 Chris Dorman, some rights reserved (CC-BY-SA 3.0)
VERSION = \"0.2.0\"
VERSION = \"0.2.1\"
EXTRA ?= dev
VERSION_EXTRA = \"$(EXTRA)\"

View File

@ -47,9 +47,11 @@ Todo list
* Add in-script functions
* New static functions
* Network sockets
* Function piping between each other
Done
----
* Simple syntax checking and error reporting
* Support for linux system calls
* Read and write from file
* Some simple functions
@ -58,6 +60,12 @@ Done
Changelog
----
V0.2.1
* Added "dec" decode function
* Added "enc" encode function
* Added system "exec" function
* Added basic syntax handling, for a more uniform language
V0.2.0
* Added "delete" function
* Added embedded variable handling to SS functions (variables can be used like everywhere!)

View File

@ -37,6 +37,9 @@ int process_line(char *line)
parsed = parse_vars(tok_srch);
if(parsed != NULL)
{
if(strtok(NULL, "\"") == NULL)
syn_error("ss:error:print syntax error, missing end quote");
printf("%s\n", parsed);
}
else
@ -49,6 +52,9 @@ int process_line(char *line)
else if(strncmp("sleep",tok_srch,5) == 0)
{
tok_srch = strtok(NULL, " ");
if(strcmp(tok_srch, "\n") == 0 ||
strcmp(tok_srch, " \n") == 0 || tok_srch == NULL)
syn_error("ss:error:sleep syntax error, need trailing integer for operation");
/* if there is a new line, remove it */
if(tok_srch[strlen(tok_srch)-1] == '\n')
@ -63,6 +69,10 @@ int process_line(char *line)
{
char *var_conv;
tok_srch = strtok(NULL, "\"");
if(strcmp(tok_srch, "\n") == 0 ||
strcmp(tok_srch, " \n") == 0 || tok_srch == NULL)
syn_error("ss:error:encode syntax error, requires data in quotes");
var_conv = parse_vars(tok_srch);
if(var_conv != NULL)
{
@ -77,6 +87,10 @@ int process_line(char *line)
{
char *var_conv;
tok_srch = strtok(NULL, "\"");
if(strcmp(tok_srch, "\n") == 0 ||
strcmp(tok_srch, " \n") == 0 || tok_srch == NULL)
syn_error("ss:error:decode syntax error, requires data in quotes");
var_conv = parse_vars(tok_srch);
if(var_conv != NULL)
{
@ -92,6 +106,10 @@ int process_line(char *line)
char *cmd_line;
int return_val;
tok_srch = strtok(NULL, "\"");
if(strcmp(tok_srch, "\n") == 0 ||
strcmp(tok_srch, " \n") == 0 || tok_srch == NULL)
syn_error("ss:error:exec syntax error, requires argument in quotes");
cmd_line = parse_vars(tok_srch);
return_val = system(cmd_line);
if(return_val != 0)
@ -108,6 +126,11 @@ int process_line(char *line)
FILE* write_file = NULL;
/* strtok to filename of function */
tok_srch = strtok(NULL, "\"");
/* Check to see if syntax is correct */
if(strcmp(tok_srch, "\n") == 0 ||
strcmp(tok_srch, " \n") == 0 || tok_srch == NULL)
syn_error("ss:error:write syntax error, requires filename followed by data; both in quotes");
/* open file */
filename = parse_vars(tok_srch);
write_file = fopen(filename, "w");
@ -122,8 +145,13 @@ int process_line(char *line)
tok_srch = strtok(NULL, "\"");
tok_srch = strtok(NULL, "\"");
if(strcmp(tok_srch, "\n") == 0 ||
strcmp(tok_srch, " \n") == 0 || tok_srch != NULL)
syn_error("ss:error:write syntax error");
strcmp(tok_srch, " \n") == 0 || tok_srch == NULL) {
fclose(write_file);
syn_error("ss:error:write syntax error on data entry (are you quoted?)");
}
if(strtok(NULL, "\"") == NULL)
syn_error("ss:error:write syntax error, missing end quote");
file_content = parse_vars(tok_srch);
fprintf(write_file, "%s\n", file_content);
@ -139,6 +167,9 @@ int process_line(char *line)
/* strtok to filename of function */
tok_srch = strtok(NULL, "\"");
if(strcmp(tok_srch, "\n") == 0 ||
strcmp(tok_srch, " \n") == 0 || tok_srch == NULL)
syn_error("ss:error:read syntax error, missing filename / in quotes");
/* Pull any variables out of the file name
that may be, and BAM, variable fill! */
@ -165,6 +196,10 @@ int process_line(char *line)
else if(strncmp("delete", tok_srch, 6) == 0) {
char *del_filename;
tok_srch = strtok(NULL, "\"");
if(strcmp(tok_srch, "\n") == 0 ||
strcmp(tok_srch, " \n") == 0 || tok_srch == NULL)
syn_error("ss:error:delete syntax error, missing file argument");
/* Pull variables out of filename if any */
del_filename = parse_vars(tok_srch);
if(access(del_filename, F_OK) == 0)
@ -197,6 +232,7 @@ int process_line(char *line)
int varc = get_var_count();
char *varname_tmp = tok_srch;
tok_srch = strtok(NULL, "=");
// Don't check if variable is blank, if so let it fly!
set_var(varc, varname_tmp, parse_vars(strip_nl(tok_srch)));
/* printf("ss: var '%s' -> %s", varname_tmp, get_var_data(varname_tmp)); */
}

View File

@ -22,7 +22,7 @@ print "Sleeping before writing '%ss_file_content%' to '%ss_filename%'"
sleep 1
# Writes the content of ss_file_content to ss_filename
write "%ss_filename%"
write "%ss_filename%" "%ss_file_content%"
print "Data written to %ss_filename%:"
# Reads data and prints to screen from ss_filename