More strings#73
Merged
Merged
Conversation
New string functions to remove whitespace from strings: - TRIM$(str$) removes leading and trailing spaces/tabs - LTRIM$(str$) removes leading spaces/tabs only - RTRIM$(str$) removes trailing spaces/tabs only Implementation: 3 new enum symbols, rword[] entries, code gen cases in basfun.c, and 68000 assembly runtime in new string2.s module. Verified on emulator: all 7 ASSERT tests pass. Co-Authored-By: Claude Opus 4.6 <[email protected]>
New functions for string searching and matching: - STARTSWITH(str$, prefix$) returns -1 if str$ begins with prefix$ - ENDSWITH(str$, suffix$) returns -1 if str$ ends with suffix$ - RINSTR([offset,] str$, find$) reverse search, returns last position All return LONG type. Assembly runtime in string2.s. Verified on emulator: all ASSERT tests pass (Phase 1 trim + Phase 2 search). Co-Authored-By: Claude Opus 4.6 <[email protected]>
New string transformation functions: - REPLACE$(str$, find$, repl$) replaces all occurrences of find$ with repl$ - REVERSE$(str$) reverses a string - REPEAT$(str$, count) repeats a string N times Assembly runtime in string2.s with MAXSTRINGSIZE bounds checking. Verified on emulator: all ASSERT tests pass (Phases 1-3). Co-Authored-By: Claude Opus 4.6 <[email protected]>
New string padding functions: - LPAD$(str$, width, pad$) left-pads to target width with pad character - RPAD$(str$, width, pad$) right-pads to target width with pad character Both use first character of pad$ string. If str$ is already >= width, returns str$ unchanged. Assembly runtime in string2.s. Verified on emulator: all ASSERT tests pass (Phases 1-4). Co-Authored-By: Claude Opus 4.6 <[email protected]>
FMT$(format$, arg1, arg2, ...) supports up to 8 arguments: - %d/%ld for decimal integers - %x/%lx for hexadecimal (uppercase on Amiga platform) - %s for string interpolation - %c for single character - %% for literal percent - Width/padding modifiers (e.g., %08x) Implementation: special varargs codegen stores args in BSS buffer, assembly state machine in string2.s walks format string, delegates integer formatting to _sprintf. Verified on emulator: all 8 ASSERT tests pass. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Extends existing MID$ function with a statement form: MID$(x$, pos[, len]) = rhs$ that overwrites bytes in a string variable in-place, matching standard BASIC dialects. Co-Authored-By: Claude Opus 4.6 <[email protected]>
37 new assertions covering: LTRIM$/RTRIM$ empty/whitespace/tabs, STARTSWITH/ENDSWITH exact match and empty strings, RINSTR edge cases, REPEAT$ empty source, REPLACE$ start/end/consecutive, REVERSE$ two chars, LPAD$/RPAD$ empty strings, FMT$ negative int/multi strings/empty format, MID$ statement pos=1/capped rhs/empty rhs/pos beyond end. Co-Authored-By: Claude Opus 4.6 <[email protected]>
…tegory Add ref.txt entries for ENDSWITH, FMT$, LPAD$, LTRIM$, REPEAT$, REPLACE$, REVERSE$, RINSTR, RPAD$, RTRIM$, STARTSWITH, TRIM$, and update MID$ with statement form. Add corresponding quickref.txt entries. Move 9 string-related test files from syntax/ to strings/ category: case_convert, fmt_func, lcase, mid_stmt, pad_funcs, search_funcs, transform_funcs, trim, ucase. Co-Authored-By: Claude Opus 4.6 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.