odds and ends
This commit is contained in:
parent
78f56d916c
commit
c6b416d2d4
2
limine
2
limine
@ -1 +1 @@
|
|||||||
Subproject commit eecf8d682a749701691e31b89f66f330f525c611
|
Subproject commit e0e61c946933696453f591da525ab1f8a66a553d
|
||||||
BIN
obj/src/int.c.o
BIN
obj/src/int.c.o
Binary file not shown.
BIN
obj/src/main.c.o
BIN
obj/src/main.c.o
Binary file not shown.
3
run.sh
3
run.sh
@ -1 +1,2 @@
|
|||||||
/mnt/c/'Program Files'/qemu/qemu-system-x86_64.exe image.hdd
|
qemu-system-x86_64 image.hdd
|
||||||
|
#/mnt/c/'Program Files'/qemu/qemu-system-x86_64.exe image.hdd
|
||||||
|
|||||||
@ -205,12 +205,11 @@ void kmain() {
|
|||||||
|
|
||||||
#define LINES 40
|
#define LINES 40
|
||||||
size_t max_len = MAX_LINE_LEN;
|
size_t max_len = MAX_LINE_LEN;
|
||||||
char* line = getline_alloc(max_len);
|
|
||||||
char* lines[LINES];
|
char* lines[LINES];
|
||||||
|
|
||||||
size_t n_lines = 0;
|
size_t n_lines = 0;
|
||||||
for(n_lines = 0; n_lines < LINES; n_lines++) {
|
for(n_lines = 0; n_lines < LINES; n_lines++) {
|
||||||
line = getline_alloc(max_len);
|
char* line = getline_alloc(max_len);
|
||||||
if(!line)
|
if(!line)
|
||||||
break;
|
break;
|
||||||
if(line[0] == 'F' && line[1] == 'I' && line[2] == '\n')
|
if(line[0] == 'F' && line[1] == 'I' && line[2] == '\n')
|
||||||
|
|||||||
@ -2,17 +2,10 @@
|
|||||||
|
|
||||||
#include "iden.h"
|
#include "iden.h"
|
||||||
#include "lex.h"
|
#include "lex.h"
|
||||||
#include "../print.h"
|
#include "../lib/stdio.h"
|
||||||
|
|
||||||
static int lex_error(struct file* state, const char* err) {
|
static int lex_error(struct file* state, const char* err) {
|
||||||
print(state->name);
|
printf("%s:%d:%d: %s\n", state->name, state->row+1, state->col+1, err);
|
||||||
print("[");
|
|
||||||
print16(state->row+1);
|
|
||||||
print(":");
|
|
||||||
print16(state->col+1);
|
|
||||||
print("] ");
|
|
||||||
print(err);
|
|
||||||
print("\n");
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +39,7 @@ size_t token_next = 0;
|
|||||||
static struct token* tok(enum tokentype type, struct file* state, int col, void* val) {
|
static struct token* tok(enum tokentype type, struct file* state, int col, void* val) {
|
||||||
struct token* ret = &token_pool[token_next];
|
struct token* ret = &token_pool[token_next];
|
||||||
if(++token_next >= MAX_TOK) {
|
if(++token_next >= MAX_TOK) {
|
||||||
print("OUT OF TOKENS!!!!");
|
printf("OUT OF TOKENS!!!!");
|
||||||
hang();
|
hang();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,12 +112,11 @@ static int parse_num(struct file* state, int save, int sign) {
|
|||||||
if(ch == '0' && state->lines[state->row][state->col+1] == 'x') {
|
if(ch == '0' && state->lines[state->row][state->col+1] == 'x') {
|
||||||
state->col+=2;
|
state->col+=2;
|
||||||
if(!isxdigit(state->lines[state->row][state->col])) {
|
if(!isxdigit(state->lines[state->row][state->col])) {
|
||||||
print("On input: '");
|
printf("On input: '%c'\n", state->lines[state->row][state->col]);
|
||||||
printn(&state->lines[state->row][state->col], 1);
|
|
||||||
print("'\n");
|
|
||||||
lex_error(state, "expected hexadecimal digits in hex literal");
|
lex_error(state, "expected hexadecimal digits in hex literal");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(isxdigit(state->lines[state->row][state->col])) {
|
while(isxdigit(state->lines[state->row][state->col])) {
|
||||||
num <<= 4;
|
num <<= 4;
|
||||||
ch = toupper(state->lines[state->row][state->col]);
|
ch = toupper(state->lines[state->row][state->col]);
|
||||||
@ -243,12 +235,7 @@ int lex(struct file* state) {
|
|||||||
*state->tail = tok(state->lines[state->row][state->col-1], state, save, NULL);
|
*state->tail = tok(state->lines[state->row][state->col-1], state, save, NULL);
|
||||||
} else {
|
} else {
|
||||||
lex_error(state, "unrecognized character");
|
lex_error(state, "unrecognized character");
|
||||||
print("Character: (0x");
|
printf("Character: (0x%x) '%c'\n", ch, ch);
|
||||||
u8 ch = state->lines[state->row][state->col];
|
|
||||||
print8(ch);
|
|
||||||
print(") '");
|
|
||||||
printn(&ch,1);
|
|
||||||
print("'\n");
|
|
||||||
state->col++;
|
state->col++;
|
||||||
return 1 + lex(state);
|
return 1 + lex(state);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user