Commit Graph

4 Commits

Author SHA1 Message Date
Bob Nystrom
b301e9f119 feat: implement eager * operator for String and List to repeat content by integer count
Add `*(count)` method to both String and List classes in wren_core.wren, enabling eager repetition of string characters or list elements. The operator validates that count is a non-negative integer, aborting with a clear error message otherwise. For strings, concatenates the original string count times; for lists, builds a new list by adding all elements count times. Includes comprehensive test cases for normal, zero, and edge-case inputs, plus error tests for negative, non-integer, and non-numeric counts. Also refactors existing list plus tests to use inline expressions and adds a plus_not_iterable error test.
2016-02-24 15:48:03 +00:00
Bob Nystrom
58d4dfc2db refactor: eagerly evaluate interpolated expressions in string compilation
Remove the deferred function compilation for interpolation parts and instead evaluate them directly during string parsing. This simplifies the compiler by eliminating the need for String.interpolate_() and the associated closure creation, replacing it with a direct list construction and join() call.
2015-11-23 15:08:14 +00:00
Bob Nystrom
920b3e2a32 feat: implement string interpolation with %(expr) syntax in compiler and core library
Add lexer support for `TOKEN_INTERPOLATION` to split string literals at interpolation points, introduce `MAX_INTERPOLATION_NESTING` limit of 8, and compile interpolated strings by emitting calls to `String.interpolate_()`. Optimize list and map literal construction with new `addCore_` primitives to reduce stack churn. Update `String`, `List`, and `Map` `toString` methods in core library to use interpolation syntax, and migrate all benchmark and test files from explicit concatenation to interpolated strings.
2015-11-11 15:55:48 +00:00
Bob Nystrom
c03d86c28b chore: move core.wren source from builtin/ to src/vm/ and update build paths
- Remove builtin/README.md explaining the .wren to .wren.inc conversion process
- Update src/README.md to document new aux/ directory for optional modules
- Fix generated file headers in wren_core.wren.inc and wren_aux_random.wren.inc to point to new source locations
- Update Makefile pattern rule to look for .wren sources in src/vm/ instead of builtin/
- Adjust wren_to_c_string.py to strip both "aux_" and "wren_" prefixes when deriving module names
2015-10-18 05:17:10 +00:00