Bob Nystrom
2490e6a425
feat: add subscript operator for array indexing and string character access
...
Implement the `[]` subscript operator as an infix parser at `PREC_CALL` precedence, compiling to a method call on the receiver. Add a `string_subscript` primitive that handles integer indices (including negative for reverse indexing), returns `null` for out-of-bounds or non-integer arguments, and returns a one-character string. Register the `[ ]` method on the string class and include tests for basic indexing, negative indices, out-of-bounds, wrong types, and non-integer indices.
2013-11-24 18:45:07 +00:00
..
2013-11-20 02:24:58 +00:00
2013-11-13 15:10:52 +00:00
2013-11-13 15:10:52 +00:00
2013-11-13 15:10:52 +00:00
2013-11-13 15:10:52 +00:00
2013-11-13 15:10:52 +00:00
2013-11-13 15:10:52 +00:00
2013-11-13 15:10:52 +00:00
2013-11-13 15:10:52 +00:00
2013-11-07 15:04:25 +00:00
2013-11-13 15:10:52 +00:00
2013-11-04 05:38:58 +00:00
2013-11-13 19:05:03 +00:00
2013-11-08 01:07:32 +00:00
2013-11-08 01:07:32 +00:00
2013-11-14 01:09:47 +00:00
2013-11-14 01:09:47 +00:00
2013-11-14 01:09:47 +00:00
2013-11-20 15:20:16 +00:00
2013-11-10 05:32:57 +00:00
2013-11-09 19:38:01 +00:00
2013-11-09 19:38:01 +00:00
2013-11-23 22:55:05 +00:00
2013-11-23 22:55:05 +00:00
2013-11-23 22:55:05 +00:00
2013-11-23 22:55:05 +00:00
2013-11-06 15:47:47 +00:00
2013-11-15 02:25:28 +00:00
2013-11-06 15:47:47 +00:00
2013-11-13 15:10:52 +00:00
2013-11-20 02:24:58 +00:00
2013-11-08 01:07:32 +00:00
2013-11-09 19:38:01 +00:00
2013-11-09 19:38:01 +00:00
2013-11-09 19:18:27 +00:00
2013-11-14 18:27:33 +00:00
2013-11-10 19:46:13 +00:00
2013-11-01 13:57:21 +00:00
2013-11-06 02:22:22 +00:00
2013-11-10 05:32:57 +00:00
2013-11-10 05:32:57 +00:00
2013-11-10 05:32:57 +00:00
2013-11-10 05:32:57 +00:00
2013-11-10 05:32:57 +00:00
2013-11-13 15:10:52 +00:00
2013-11-10 05:32:57 +00:00
2013-11-10 05:32:57 +00:00
2013-11-10 05:32:57 +00:00
2013-11-10 05:32:57 +00:00
2013-11-20 02:24:58 +00:00
2013-11-18 17:19:03 +00:00
2013-11-18 17:19:03 +00:00
2013-11-18 17:19:03 +00:00
2013-11-17 18:04:02 +00:00
2013-10-28 13:53:51 +00:00
2013-11-05 17:57:57 +00:00
2013-11-24 05:00:47 +00:00
2013-11-24 05:00:47 +00:00
2013-11-24 18:45:07 +00:00
2013-11-06 04:38:16 +00:00
2013-11-09 23:42:23 +00:00
2013-11-09 23:42:23 +00:00
2013-11-09 23:42:23 +00:00
2013-10-28 14:12:39 +00:00
2013-11-06 15:47:47 +00:00
2013-11-09 19:38:01 +00:00
2013-11-23 22:55:05 +00:00
2013-11-09 19:38:01 +00:00
2013-11-09 23:42:23 +00:00
2013-11-09 19:38:01 +00:00
2013-11-18 17:19:03 +00:00