mirror of
https://github.com/gorules/zen.git
synced 2026-12-04 08:09:17 +00:00
* feat(expression): lane VM and typed-mask engine for batch and columnar evaluation Adds a register-based lane VM (core/expression/src/lane) and a typed-mask engine (core/expression/src/typed) that evaluate ZEN expressions over batches and columns, matching the stack VM's results. zen-types gains shape-backed objects and dot-path helpers; existing public APIs only grow. The lane VM has no expression size limit: deep and wide expressions are compiled and run with the same stack growth the parser uses. ZEN_EXPRESSION_CONFIG.lane (off by default) switches Isolate::run_standard and run_unary to the lane VM at runtime. Lane internals and the typed module are doc(hidden); the documented entry points are LaneProgram, LaneRunner, Session, Columns and Output. Includes an executable specification of the expression language (core/expression/tests/spec, 28,852 cases) with differential tests that run every lane path against the stack VM. zen-expression and zen-types now declare rust-version 1.88. * refactor(types): remove the shape transition cap Shapes are freed when nothing uses them, so the 4,096-children cap per shape no longer bounds memory. Shape::with, Shape::of and Shape::without now always return a shape; objects only switch to a hash map past SPILL_AT keys, as on master. * fix(expression): debug-profile stack safety and Windows test build CI runs tests in the debug profile, where frames are larger and tail recursion is not optimised. Recursive lane, typed and parser helpers now grow the stack like the rest (Const::number, the kernel builder, typed lowering and lookup, lane compile helpers, Node::member_key). The parser's closure depth counter is u32 instead of u8, so 256 nested closures no longer wrap. median([]) and empty templates no longer overflow in debug builds; release results are unchanged. The deep/wide test runs on a 256 KiB stack so unprotected recursion fails quickly in any profile. The conformance helper compares with as_str(), which is unambiguous on Windows. * fix(expression): stack checks in the lane executor, LF test data on Windows In x86-64 debug builds Executor::cold has a ~93 KB frame, so nested closures (execute -> cold -> body) could use more stack between two checks than the stack-growth margin and overflow. execute and cold now check the stack themselves; both run per instruction batch, not per row. The expression test data is checked out with LF on every platform. Windows runners converted it to CRLF, which broke multi-line spec cases.
4.3 KiB
4.3 KiB
| 1 | expression (string) | input (json 5) | output (json 5) | note |
|---|---|---|---|---|
| 2 | # Single and double quotes | |||
| 3 | 'hello' | 'hello' | ||
| 4 | "hello" | 'hello' | ||
| 5 | 'hello world' | 'hello world' | ||
| 6 | "hello world" | 'hello world' | ||
| 7 | '' | '' | ||
| 8 | "" | '' | ||
| 9 | ' ' | ' ' | ||
| 10 | ' ' | ' ' | ||
| 11 | 'a' == "a" | true | ||
| 12 | type('') | 'string' | ||
| 13 | type('a') | 'string' | ||
| 14 | len('') | 0 | ||
| 15 | len(' ') | 1 | ||
| 16 | # The other quote kind is plain text inside a string | |||
| 17 | '"' | '"' | ||
| 18 | "'" | '\'' | ||
| 19 | "it's" | 'it\'s' | ||
| 20 | "a'b'c" | 'a\'b\'c' | ||
| 21 | # Numeric-looking and keyword-looking strings stay strings | |||
| 22 | '1' | '1' | ||
| 23 | '1' == 1 | false | ||
| 24 | type('1') | 'string' | ||
| 25 | '1e3' | '1e3' | ||
| 26 | '-0' | '-0' | ||
| 27 | '0x10' | '0x10' | ||
| 28 | 'true' | 'true' | ||
| 29 | 'true' == true | false | ||
| 30 | 'null' | 'null' | ||
| 31 | 'null' == null | false | ||
| 32 | 'and' | 'and' | ||
| 33 | 'not in' | 'not in' | ||
| 34 | # Operator and punctuation characters inside strings | |||
| 35 | 'a + b' | 'a + b' | ||
| 36 | 'a, b' | 'a, b' | ||
| 37 | '[1..5]' | '[1..5]' | ||
| 38 | '{a: 1}' | '{a: 1}' | ||
| 39 | 'a.b' | 'a.b' | ||
| 40 | '?? ?:' | '?? ?:' | ||
| 41 | '#' | '#' | ||
| 42 | '$' | '$' | ||
| 43 | '${x}' | '${x}' | ||
| 44 | 'a;b' | 'a;b' | ||
| 45 | '`' | '`' | ||
| 46 | 'a`b`c' | 'a`b`c' | ||
| 47 | '//' | '//' | ||
| 48 | '/* */' | '/* */' | ||
| 49 | '%^&*=!<>' | '%^&*=!<>' | ||
| 50 | '@~|' | '@~|' | ||
| 51 | # No escape sequences: a backslash is an ordinary character | |||
| 52 | 'a\nb' | 'a\\nb' | question: string literals have no escape sequences so \n stays two characters | |
| 53 | len('a\nb') | 4 | question: string literals have no escape sequences so \n stays two characters | |
| 54 | '\t' | '\\t' | question: string literals have no escape sequences | |
| 55 | '\u0041' | '\\u0041' | question: string literals have no escape sequences | |
| 56 | '\\' | '\\\\' | question: string literals have no escape sequences so \\ stays two backslashes | |
| 57 | '\' | '\\' | question: a trailing backslash does not escape the closing quote | |
| 58 | '\' | '\\' | ||
| 59 | 'a\'b' | !error | question: \' does not escape the quote so the literal is unterminated | |
| 60 | 'a''b' | !error | question: doubling the quote is not an escape either, so a quote cannot appear in a same-quoted string | |
| 61 | '''' | !error | ||
| 62 | # Unicode | |||
| 63 | 'é' | 'é' | ||
| 64 | 'ü' | 'ü' | ||
| 65 | '日本語' | '日本語' | ||
| 66 | 'Привет' | 'Привет' | ||
| 67 | 'مرحبا' | 'مرحبا' | ||
| 68 | '😀' | '😀' | ||
| 69 | '👨👩👧' | '👨👩👧' | ||
| 70 | 'a😀b' | 'a😀b' | ||
| 71 | 'é' == 'é' | true | ||
| 72 | '😀' + '😀' | '😀😀' | ||
| 73 | len('é') | 1 | bug: len counts UTF-8 bytes instead of characters | |
| 74 | len('日本語') | 3 | bug: len counts UTF-8 bytes instead of characters | |
| 75 | len('😀') | 1 | bug: len counts UTF-8 bytes instead of characters | |
| 76 | ['é', '😀'] | ['é', '😀'] | ||
| 77 | # Multi-line strings keep the newline | |||
| 78 | 'a b' | 'a\nb' | ||
| 79 | "a b" | 'a\nb' | ||
| 80 | len('a b') | 3 | ||
| 81 | ' ' | '\n' | ||
| 82 | # Tabs inside strings are kept | |||
| 83 | 'a b' | 'a\tb' | ||
| 84 | # Unterminated strings | |||
| 85 | ' | !error | ||
| 86 | 'abc | !error | ||
| 87 | "abc | !error | ||
| 88 | "abc' | !error | ||
| 89 | 'a' + 'b | !error | ||
| 90 | ['a] | !error | ||
| 91 | {a: 'b} | !error | ||
| 92 | # Adjacent strings do not concatenate | |||
| 93 | 'a' 'b' | !error | ||
| 94 | 'a''' | !error | ||
| 95 | 'a' + 'b' | 'ab' | ||
| 96 | # Strings from the input | |||
| 97 | s | {s: 'x'} | 'x' | |
| 98 | s | {s: ''} | '' | |
| 99 | s | {s: 'é😀'} | 'é😀' | |
| 100 | s | {s: 'a\nb'} | 'a\nb' | |
| 101 | s | {s: null} | null | |
| 102 | s | {} | null | |
| 103 | s == 'x' | {s: 'x'} | true | |
| 104 | s == 'x' | {s: 'X'} | false | |
| 105 | s == 'x' | {s: ''} | false | |
| 106 | s == 'x' | {s: null} | false | |
| 107 | s == 'x' | {s: 1} | false | |
| 108 | s == 'x' | {} | false | |
| 109 | s == 'é😀' | {s: 'é😀'} | true | |
| 110 | s == 'é😀' | {s: 'e😀'} | false | |
| 111 | s == 'é😀' | {s: null} | false | |
| 112 | s == 'é😀' | {} | false | |
| 113 | s == 'a\nb' | {s: 'a\\nb'} | true | question: string literals have no escape sequences |
| 114 | s == 'a\nb' | {s: 'a\nb'} | false | question: string literals have no escape sequences |
| 115 | s == 'a\nb' | {s: null} | false | |
| 116 | # Booleans | |||
| 117 | true | true | ||
| 118 | false | false | ||
| 119 | type(true) | 'bool' | ||
| 120 | type(false) | 'bool' | ||
| 121 | true == true | true | ||
| 122 | true == false | false | ||
| 123 | not true | false | ||
| 124 | not false | true | ||
| 125 | !true | false | ||
| 126 | !false | true | ||
| 127 | [true, false] | [true, false] | ||
| 128 | {t: true, f: false} | {t: true, f: false} | ||
| 129 | # Keywords are lower-case only | other spellings are identifiers | ||
| 130 | TRUE | {} | null | |
| 131 | True | {} | null | |
| 132 | FALSE | {} | null | |
| 133 | True | {True: 1} | 1 | |
| 134 | trueish | {trueish: 2} | 2 | |
| 135 | falsey | {falsey: 3} | 3 | |
| 136 | true1 | {true1: 4} | 4 | |
| 137 | # Null | |||
| 138 | null | null | ||
| 139 | type(null) | 'null' | ||
| 140 | null == null | true | ||
| 141 | null != null | false | ||
| 142 | null == false | false | ||
| 143 | null == 0 | false | ||
| 144 | null == '' | false | ||
| 145 | [null] | [null] | ||
| 146 | [null, null] | [null, null] | ||
| 147 | {a: null} | {a: null} | ||
| 148 | Null | {} | null | |
| 149 | NULL | {Null: 1, NULL: 2} | 2 | |
| 150 | nulls | {nulls: 5} | 5 | |
| 151 | nullable | {nullable: 6} | 6 | |
| 152 | null_ | {null_: 7} | 7 | |
| 153 | # Literal values compared to input values | |||
| 154 | b | {b: true} | true | |
| 155 | b | {b: false} | false | |
| 156 | b | {b: null} | null | |
| 157 | b | {} | null | |
| 158 | b == true | {b: true} | true | |
| 159 | b == true | {b: false} | false | |
| 160 | b == true | {b: 'true'} | false | |
| 161 | b == true | {b: 1} | false | |
| 162 | b == true | {b: null} | false | |
| 163 | b == true | {} | false | |
| 164 | n == null | {n: null} | true | |
| 165 | n == null | {} | true | |
| 166 | n == null | {n: 0} | false | |
| 167 | n == null | {n: ''} | false | |
| 168 | n == null | {n: false} | false | |
| 169 | n == null | {n: []} | false | |
| 170 | n == null | {n: 'null'} | false |