summaryrefslogtreecommitdiff
path: root/lexer/cpu
diff options
context:
space:
mode:
Diffstat (limited to 'lexer/cpu')
-rw-r--r--lexer/cpu/sux/cpu.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/lexer/cpu/sux/cpu.c b/lexer/cpu/sux/cpu.c
new file mode 100644
index 0000000..cd6d364
--- /dev/null
+++ b/lexer/cpu/sux/cpu.c
@@ -0,0 +1,30 @@
+#include <ctype.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+
+static char current_ext;
+
+int is_ext(char c) {
+ return (c && c != '.' && !isspace(c));
+}
+
+void cpu_error(int code) {
+
+}
+
+char *lex_inst(char *s, int *inst_len, char **ext, int *ext_len, int *ext_count) {
+ char *inst = s;
+ int count = *ext_count;
+ for (; is_ext(*s); s++);
+ *inst_len = s - inst;
+ for (; *s++ == '.' && count < MAX_QUALIFIERS;) {
+ ext[count] = s;
+ for (; is_ext(*s); s++);
+ ext_len[count] = s - ext[count];
+ (ext_len[count] <= 0) ? (cpu_error(34)) : (count++);
+ }
+ *ext_count = count;
+ current_ext = (count > 0) ? tolower(ext[0][0]) : '\0';
+ return s;
+}