c622b3f8d3959b7f3eb53f3f4aec9b9e61c76989 kent Thu Aug 15 12:03:17 2019 -0700 Added strexParseFile function, so can parse files as well as strings. Also added import operator, which is going to be so helpful for debugging and reusing complicated expressions. diff --git src/inc/strex.h src/inc/strex.h index ac5320c..403700d 100644 --- src/inc/strex.h +++ src/inc/strex.h @@ -7,25 +7,28 @@ /* Parsing out something into strex */ struct strexParse; /* A parser generated tree */ typedef char* (*StrexLookup)(void *symbols, char *key); /* Callback to lookup value of key in a symbol table. */ struct strexParse *strexParseString(char *s, char *fileName, int fileLineNumber, void *symbols, StrexLookup lookup); /* Parse out string expression in s and return root of tree. The fileName and * fileLineNumber are just used in the error message. Ideally they should help * the user navigate to where the problem was. * If symbols is non-null then it and lookup will be used together to complain * about missing variables rather than just generating empty strings when * they are referenced. */ +struct strexParse *strexParseFile(char *fileName, void *symbols, StrexLookup lookup); +/* Similar to strexParseString, but get input from a file rather than a string */ + void strexParseDump(struct strexParse *p, int depth, FILE *f); /* Dump out strexParse tree and children for debugging. Usual depth is 0. */ /* Evaluating a parsed out strex expression */ char *strexEvalAsString(struct strexParse *p, void *symbols, StrexLookup lookup); /* Evaluating a strex expression on a symbol table with a lookup function for variables and * return result as a string value. */ #endif /* STREX_H */