return val;
}
+char *tokbuf[L_LSL_TOK_MAX];
+const char* l_lsl_next_token(const char *code, u32 len, u32 *token_len) {
+ LRTS_UNUSED(code);
+ LRTS_UNUSED(len);
+
+ *token_len = 0;
+
+ return LRTS_NULL;
+}
+
struct l_lsl_value l_lsl_compile_file(struct l_lsl_vm *v, const char *path) {
struct l_lsl_value val = l_lsl_value_init();
const char *src = u_file_read(path);
+ u32 token_len;
+ u32 src_len = 0;
if (src == LRTS_NULL) {
u_log(U_LOG_CRIT, "%s: No such file or directory\n", path);
return val;
}
+ src_len = u_strnlen(src, L_LSL_SOURCE_MAX);
+
u_printf("%s\n", src);
- u_free((void*)src);
+ l_lsl_next_token(src, src_len, &token_len);
+
+ u_free((void*)src);
return val;
}
* in-game scripting interpreter
*/
+#define L_LSL_TOK_MAX 256
+#define L_LSL_SOURCE_MAX 0xFFFFFFFF
+
/* special tokens */
#define L_LWL_TOK_STR_LPAREN "("
#define L_LWL_TOK_STR_RPAREN ")"
/*
* gets the next token returns tone's length in token_len
- * the result token is placed into an interla string buffer and should not be modified
+ * the result token is placed into an internal string buffer and should not be modified
* or saved.
*/
const char* l_lsl_next_token(const char *code, u32 len, u32 *token_len);
#include "l_lsl.c"
#include "u_debug.c"
#include "u_file.c"
+#include "u_string.c"
#endif
int u_strncmp(const char *s1, const char *s2, u32 n) {
return strncmp(s1, s2, n);
}
+
--- /dev/null
+#include "u_string.h"
+
+int u_strnlen(const char *s, u32 n) {
+ u32 i = 0;
+ while (s[i++] && i < n) {
+ i++;
+ }
+ return i;
+}
int u_strncmp(const char *s1, const char *s2, u32 n);
+int u_strnlen(const char *s, u32 n);
+
#endif