Call this v0.2.1
This commit is contained in:
parent
8356d6de8a
commit
8537c1acce
2
Makefile
2
Makefile
@ -1,7 +1,7 @@
|
|||||||
# SlideScript makefile
|
# SlideScript makefile
|
||||||
# (C) Copyright 2014-2021 Chris Dorman, some rights reserved (CC-BY-SA 3.0)
|
# (C) Copyright 2014-2021 Chris Dorman, some rights reserved (CC-BY-SA 3.0)
|
||||||
|
|
||||||
VERSION = \"0.2.0\"
|
VERSION = \"0.2.1\"
|
||||||
EXTRA ?= dev
|
EXTRA ?= dev
|
||||||
VERSION_EXTRA = \"$(EXTRA)\"
|
VERSION_EXTRA = \"$(EXTRA)\"
|
||||||
|
|
||||||
|
@ -47,9 +47,11 @@ Todo list
|
|||||||
* Add in-script functions
|
* Add in-script functions
|
||||||
* New static functions
|
* New static functions
|
||||||
* Network sockets
|
* Network sockets
|
||||||
|
* Function piping between each other
|
||||||
|
|
||||||
Done
|
Done
|
||||||
----
|
----
|
||||||
|
* Simple syntax checking and error reporting
|
||||||
* Support for linux system calls
|
* Support for linux system calls
|
||||||
* Read and write from file
|
* Read and write from file
|
||||||
* Some simple functions
|
* Some simple functions
|
||||||
@ -58,6 +60,12 @@ Done
|
|||||||
|
|
||||||
Changelog
|
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
|
V0.2.0
|
||||||
* Added "delete" function
|
* Added "delete" function
|
||||||
* Added embedded variable handling to SS functions (variables can be used like everywhere!)
|
* Added embedded variable handling to SS functions (variables can be used like everywhere!)
|
||||||
|
@ -37,6 +37,9 @@ int process_line(char *line)
|
|||||||
parsed = parse_vars(tok_srch);
|
parsed = parse_vars(tok_srch);
|
||||||
if(parsed != NULL)
|
if(parsed != NULL)
|
||||||
{
|
{
|
||||||
|
if(strtok(NULL, "\"") == NULL)
|
||||||
|
syn_error("ss:error:print syntax error, missing end quote");
|
||||||
|
|
||||||
printf("%s\n", parsed);
|
printf("%s\n", parsed);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -49,6 +52,9 @@ int process_line(char *line)
|
|||||||
else if(strncmp("sleep",tok_srch,5) == 0)
|
else if(strncmp("sleep",tok_srch,5) == 0)
|
||||||
{
|
{
|
||||||
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:sleep syntax error, need trailing integer for operation");
|
||||||
|
|
||||||
/* if there is a new line, remove it */
|
/* if there is a new line, remove it */
|
||||||
if(tok_srch[strlen(tok_srch)-1] == '\n')
|
if(tok_srch[strlen(tok_srch)-1] == '\n')
|
||||||
@ -63,6 +69,10 @@ int process_line(char *line)
|
|||||||
{
|
{
|
||||||
char *var_conv;
|
char *var_conv;
|
||||||
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:encode syntax error, requires data in quotes");
|
||||||
|
|
||||||
var_conv = parse_vars(tok_srch);
|
var_conv = parse_vars(tok_srch);
|
||||||
if(var_conv != NULL)
|
if(var_conv != NULL)
|
||||||
{
|
{
|
||||||
@ -77,6 +87,10 @@ int process_line(char *line)
|
|||||||
{
|
{
|
||||||
char *var_conv;
|
char *var_conv;
|
||||||
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:decode syntax error, requires data in quotes");
|
||||||
|
|
||||||
var_conv = parse_vars(tok_srch);
|
var_conv = parse_vars(tok_srch);
|
||||||
if(var_conv != NULL)
|
if(var_conv != NULL)
|
||||||
{
|
{
|
||||||
@ -92,6 +106,10 @@ int process_line(char *line)
|
|||||||
char *cmd_line;
|
char *cmd_line;
|
||||||
int return_val;
|
int return_val;
|
||||||
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:exec syntax error, requires argument in quotes");
|
||||||
|
|
||||||
cmd_line = parse_vars(tok_srch);
|
cmd_line = parse_vars(tok_srch);
|
||||||
return_val = system(cmd_line);
|
return_val = system(cmd_line);
|
||||||
if(return_val != 0)
|
if(return_val != 0)
|
||||||
@ -108,6 +126,11 @@ int process_line(char *line)
|
|||||||
FILE* write_file = NULL;
|
FILE* write_file = NULL;
|
||||||
/* strtok to filename of function */
|
/* strtok to filename of function */
|
||||||
tok_srch = strtok(NULL, "\"");
|
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 */
|
/* open file */
|
||||||
filename = parse_vars(tok_srch);
|
filename = parse_vars(tok_srch);
|
||||||
write_file = fopen(filename, "w");
|
write_file = fopen(filename, "w");
|
||||||
@ -122,8 +145,13 @@ int process_line(char *line)
|
|||||||
tok_srch = strtok(NULL, "\"");
|
tok_srch = strtok(NULL, "\"");
|
||||||
tok_srch = strtok(NULL, "\"");
|
tok_srch = strtok(NULL, "\"");
|
||||||
if(strcmp(tok_srch, "\n") == 0 ||
|
if(strcmp(tok_srch, "\n") == 0 ||
|
||||||
strcmp(tok_srch, " \n") == 0 || tok_srch != NULL)
|
strcmp(tok_srch, " \n") == 0 || tok_srch == NULL) {
|
||||||
syn_error("ss:error:write syntax error");
|
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);
|
file_content = parse_vars(tok_srch);
|
||||||
fprintf(write_file, "%s\n", file_content);
|
fprintf(write_file, "%s\n", file_content);
|
||||||
@ -139,6 +167,9 @@ int process_line(char *line)
|
|||||||
|
|
||||||
/* strtok to filename of function */
|
/* strtok to filename of function */
|
||||||
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:read syntax error, missing filename / in quotes");
|
||||||
|
|
||||||
/* Pull any variables out of the file name
|
/* Pull any variables out of the file name
|
||||||
that may be, and BAM, variable fill! */
|
that may be, and BAM, variable fill! */
|
||||||
@ -165,6 +196,10 @@ int process_line(char *line)
|
|||||||
else if(strncmp("delete", tok_srch, 6) == 0) {
|
else if(strncmp("delete", tok_srch, 6) == 0) {
|
||||||
char *del_filename;
|
char *del_filename;
|
||||||
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:delete syntax error, missing file argument");
|
||||||
|
|
||||||
/* Pull variables out of filename if any */
|
/* Pull variables out of filename if any */
|
||||||
del_filename = parse_vars(tok_srch);
|
del_filename = parse_vars(tok_srch);
|
||||||
if(access(del_filename, F_OK) == 0)
|
if(access(del_filename, F_OK) == 0)
|
||||||
@ -197,6 +232,7 @@ int process_line(char *line)
|
|||||||
int varc = get_var_count();
|
int varc = get_var_count();
|
||||||
char *varname_tmp = tok_srch;
|
char *varname_tmp = tok_srch;
|
||||||
tok_srch = strtok(NULL, "=");
|
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)));
|
set_var(varc, varname_tmp, parse_vars(strip_nl(tok_srch)));
|
||||||
/* printf("ss: var '%s' -> %s", varname_tmp, get_var_data(varname_tmp)); */
|
/* printf("ss: var '%s' -> %s", varname_tmp, get_var_data(varname_tmp)); */
|
||||||
}
|
}
|
||||||
|
2
test.ss
2
test.ss
@ -22,7 +22,7 @@ print "Sleeping before writing '%ss_file_content%' to '%ss_filename%'"
|
|||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
# Writes the content of ss_file_content to ss_filename
|
# 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%:"
|
print "Data written to %ss_filename%:"
|
||||||
# Reads data and prints to screen from ss_filename
|
# Reads data and prints to screen from ss_filename
|
||||||
|
Loading…
x
Reference in New Issue
Block a user