Numbers work. Calls do not work.

This commit is contained in:
Jacob Signorovitch 2024-10-16 08:13:32 -04:00
parent 63f5064ba9
commit 3c56290448
2 changed files with 6 additions and 4 deletions

View File

@ -77,7 +77,7 @@ void lexer_do_call(Lexer* lexer) {
for (; *lexer->cchar && (isblank(lexer->cchar) || *lexer->cchar == '\n'); lexer_inc(lexer)); for (; *lexer->cchar && (isblank(lexer->cchar) || *lexer->cchar == '\n'); lexer_inc(lexer));
for (callsz = 0; *lexer->cchar && isalpha(*lexer->cchar); callsz++) for (callsz = 0; *lexer->cchar && (!isdigit(*lexer->cchar)); callsz++)
lexer_inc(lexer); lexer_inc(lexer);
char* call = malloc(callsz + 1); char* call = malloc(callsz + 1);

View File

@ -10,15 +10,17 @@ int main(int argc, char** argv) {
Dstr* cline = dstr_init(); // The current line. Dstr* cline = dstr_init(); // The current line.
printf("> "); printf("> ");
fflush(stdout); fflush(stdout);
for (char cch; (cch = getchar() != EOF);) { for (char cch; (cch = getc(stdin)) != '\n';) {
dstr_appendch(cline, fgetc(stdin)); log_dbgf("cchar: %c", cch);
dstr_appendch(cline, cch);
} }
log_dbgf("cline: %s", cline->buf);
if (cline->ln > 0) { if (cline->ln > 0) {
Lexer* lexer = lexer_init(cline->buf); Lexer* lexer = lexer_init(cline->buf);
lexer_lex(lexer); lexer_lex(lexer);
printf("\n=%s\n", token_to_dstr(lexer->tokens[0])->buf); printf("\n=%s\n", token_to_dstr(lexer->tokens[0])->buf);
} }
} }
} }