provide (main)
let const_true bool = true
-#let const_false bool = false
-#let const_uint int = 123
-#let const_string string = "
+let const_false bool = false
+let const_uint int = 123
+let const_string string = ""
var var_true bool = true
var var_false bool = false
}
void lex(Parser* ctx) {
+ ctx->tok.file = ctx->file->path;
ctx->tok.type = T_NONE;
while (ctx->tok.type == T_NONE) {
if (!ctx->file) {
}
}
+static LexFile* get_file(Parser* p, char* path) {
+ LexFile* lf = p->file;
+ while (lf && strcmp(lf->path, path))
+ lf = lf->next;
+ if (!lf) {
+ lf = p->done;
+ while (lf && strcmp(lf->path, path))
+ lf = lf->next;
+ }
+ return lf;
+}
+
void lexprintpos(Parser* p, FILE* file, Tok* tok) {
size_t line = 1, col = 1;
- char* data = p->file->fbeg;
+ char* data = get_file(p, tok->file)->fbeg;
char* end = data + tok->offset;
for (; *data && data < end; data++) {
if (*data == '\n') {
col++;
}
}
- fprintf(file, "%s:%zu:%zu:", p->file->path, line, col);
+ fprintf(file, "%s:%zu:%zu:", tok->file, line, col);
}