summaryrefslogtreecommitdiff
path: root/lexer/cpu/sux/cpu.c
blob: cd6d36447a13f3ea9c5beb1c73609c62912ecee1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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;
}