summaryrefslogtreecommitdiff
path: root/tags
AgeCommit message (Collapse)Author
2026-02-28Clean up scanner_run() and interpret_run(): narrow signatures, fix SoC [SoC/DIP]Paul Buetow
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>
2026-02-28Refactor _term() by extracting _term_ident(), _term_array_literal(), ↵Paul Buetow
_term_paren() [SRP] _term() was ~130 lines mixing literal push, array literal construction, identifier resolution, parenthesized expressions, and defined/undef/syms. Extracted three static helpers: - _term_ident(): resolves TT_IDENT as array access, builtin call, self-defined function/proc call, or variable/procedure (~90 lines; acceptable given the complexity of identifier resolution) - _term_array_literal(): builds an array from [expr, ...] syntax - _term_paren(): evaluates a parenthesised expression and checks ')' _term() is now a ~100-line dispatcher. The defined/undef/syms cases remain inline as they are self-contained ~10-line blocks. Also fixes a latent double-assignment bug in _term_array_literal(): the original `TokenType tt = tt = p_interpret->tt;` is now `= p_interpret->tt;`. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28Decouple functions.c from interpreter array-LHS private state [Coupling]Paul Buetow
functions.c::_op_assign() was reading p_interpret->p_token_array_lhs and p_interpret->i_array_lhs_index directly — a hidden cross-module coupling where the functions module reached into interpreter-private state. Pass the array-LHS context as explicit parameters instead: - _op_assign() gains Token *p_array_lhs, int i_lhs_idx params - _process() propagates them to _op_assign() - function_process() propagates them from the call site In interpret.c the "restore" lines that set p_interpret->p_token_array_lhs and p_interpret->i_array_lhs_index before calling function_process() are removed; instead p_lhs and i_lhs_idx are passed directly. The three non-array-LHS call sites pass NULL / 0. _op_assign() no longer touches Interpret internals for the array assignment path. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28Refactor _process() by extracting per-operator handler functions [SRP]Paul Buetow
_process() was a 510-line function with a nested switch(operator) x switch(type) structure. Extracted 17 static helper functions: - _resolve_composite_op(): maps two-token operator pairs (!=, ==, <=, >=, <<, >>) to their canonical single TokenType - _op_assign(): handles variable and array-element assignment - _op_add(), _op_sub(), _op_mult(), _op_div(): arithmetic operators - _op_eq(), _op_neq(), _op_lt(), _op_gt(), _op_le(), _op_ge(): comparison operators (result always TT_INTEGER) - _op_and(), _op_or(), _op_xor(), _op_lshift(), _op_rshift(): bitwise operators (doubles/strings coerced to int) _process() is now a ~70-line dispatcher. Assignment is guarded by `else if` so it only fires when p_token_op2 == NULL, preserving the original semantics exactly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20Add README.md and array slicing supportPaul Buetow
2026-02-19Implement function named arguments, ret, and multiple return valuesPaul Buetow
- Add FuncDef struct to symbol.h/symbol.c: holds body token list, strdup'd param names, and param count; replaces the bare List* that SYM_FUNCTION used to store; funcdef_delete frees param strings and body list (tokens are GC-managed) - Add CONTROL_RET to ControlType so ret can propagate cleanly through the interpreter's control-flow stack - Update _func_decl to parse optional (p1, p2, ...) param list and store a FuncDef* instead of a raw List* - Implement case TT_RET in _control: clears intermediate stack values, evaluates comma-separated return expressions, sets CONTROL_RET - Propagate CONTROL_RET in all loop bodies (while/until, loop, do) without clearing it; while/until rescues return values from the temporary condition stack before it is destroyed - Update _term call site to support parenthesised func(arg1, arg2) syntax alongside the existing no-parens style for backward compat - Modify interpret_subprocess to merge the sub's stack into the parent when CONTROL_RET is active so return values survive teardown - Update function_process_self_defined SYM_FUNCTION case to pop and bind named args, run the body, then clear CONTROL_RET - Add -D_POSIX_C_SOURCE=200809L to Makefile CFLAGS for strdup under -std=c99 -pedantic - Add examples/func_args_ret.fy covering zero-arg, single-arg, two-arg, conditional ret, multiple return values, and old-style no-parens backward compat Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-19migrate build system from BSD make (pmake) to GNU makePaul Buetow
- Replace BSD make != shell assignment with $(shell ...) idiom - Replace static $(OBJS): rule + sed hack with %.o: %.c pattern rule - Use $(MAKE) for all recursive make invocations - Update CLAUDE.md to document GNU make instead of pmake - Build verified clean on Fedora (GCC 15, all 14 examples pass) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2008-11-09splitted function.c into function.c and functions.cPaul Buetow
2008-11-07one step further for arrays.Paul Buetow
2008-11-04big step forward for arrays in fype. Paul Buetow
2008-11-04astylePaul Buetow
2008-11-04array_delete_iterate implemented..Paul Buetow
2008-11-04array_new_sizePaul Buetow
array_new_copy implemented
2008-10-28initial references support.Paul Buetow
run "make headers"
2008-10-26added the "scope" functionPaul Buetow
2008-10-25make headersPaul Buetow
2008-10-20Improved GC debugging.Paul Buetow
Debugging printings now labeled with DEBUG::$NAME::$ETC::..:
2008-10-18backdowngradePaul Buetow