diff options
| author | Paul Buetow <paul@buetow.org> | 2026-02-28 16:15:57 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-02-28 16:15:57 +0200 |
| commit | 2a2227d529f3788b8e08752d37deb1a449f3b9bc (patch) | |
| tree | 09a840230ca824a3df5491a3cc9263b72955f1a9 /src/core/scanner.h | |
| parent | 5f557ebafb596755cb3047cbdafa6122166c26ac (diff) | |
Clean up scanner_run() and interpret_run(): narrow signatures, fix SoC [SoC/DIP]
Three issues resolved:
1. scanner_run() no longer takes Fype*. New signature:
scanner_run(List*, Tupel*, char **c_filename_out)
Verbose-mode list_iterate() and basename extraction moved to
fype_run() (the composition root), leaving scanner_run() as pure
tokenizer: open source -> tokenize -> post-process -> return filename.
2. interpret_run() no longer takes Fype*. New signature:
interpret_run(List *p_list_token, Hash *p_hash_syms)
Fype* unpacking happens in fype_run(); interpret.h no longer includes
fype.h. scanner.h no longer includes fype.h either.
3. _CODESTR_INDEX file-global (which made the scanner non-reentrant)
moved into the Scanner struct as i_codestr_index, initialized to 0
in scanner_new(). _scanner_has_next_char() and _scanner_get_next_char()
use p_scanner->i_codestr_index instead.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'src/core/scanner.h')
| -rw-r--r-- | src/core/scanner.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/core/scanner.h b/src/core/scanner.h index 5156430..fb2208e 100644 --- a/src/core/scanner.h +++ b/src/core/scanner.h @@ -40,8 +40,9 @@ #include <ctype.h> #include "token.h" -#include "../fype.h" #include "../data/dat.h" +#include "../data/list.h" +#include "../data/tupel.h" #define scanner_get_list_token(s) s->p_list_token #define scanner_get_fp(s) s->fp @@ -52,6 +53,9 @@ typedef struct { int i_current_line_nr; int i_current_pos_nr; int i_num_tokenends; + /* Index into c_codestring for inline (-e) mode; replaces the old + * file-global _CODESTR_INDEX so the scanner is reentrant. */ + int i_codestr_index; char *c_filename; char *c_codestring; FILE *fp; @@ -62,7 +66,11 @@ typedef struct { Scanner *scanner_new(List *p_list_token, Tupel *p_tupel_argv); void scanner_post_task(Scanner *p_scanner); void scanner_delete(Scanner *p_scanner); -void scanner_run(Fype *p_fype); +/* Tokenise source and post-process into p_list_token. + * Sets *c_filename_out to the source filename (NULL for inline -e mode); + * the caller owns that pointer (do not free it). */ +void scanner_run(List *p_list_token, Tupel *p_tupel_argv, + char **c_filename_out); void scanner_add_token(Scanner *p_scanner, char **cc_token, int *p_token_len, TokenType tt_cur); TokenType scanner_get_tt_cur(char *c_token); |
