(expr, alias)
| 2140 | }; |
| 2141 | } |
| 2142 | function peg$f243(expr, alias) { |
| 2143 | // General expression support: handles boolean expressions, comparisons, arithmetic, |
| 2144 | // property access (n.prop), variable references, etc. |
| 2145 | // Normalize simple cases to legacy format for backward compatibility |
| 2146 | // Handle primitive values (null, boolean, numbers) that don't have a type property |
| 2147 | if (expr === null || expr === undefined || typeof expr !== 'object') { |
| 2148 | return { |
| 2149 | type: 'ReturnItem', |
| 2150 | expression: expr, |
| 2151 | ...(alias && { alias: alias[3] }) |
| 2152 | }; |
| 2153 | } |
| 2154 | if (expr.type === 'VariableRef') { |
| 2155 | return { |
| 2156 | type: 'ReturnItem', |
| 2157 | variable: expr.variable, |
| 2158 | ...(alias && { alias: alias[3] }) |
| 2159 | }; |
| 2160 | } |
| 2161 | if (expr.type === 'PropertyAccess') { |
| 2162 | return { |
| 2163 | type: 'ReturnItem', |
| 2164 | variable: expr.variable, |
| 2165 | property: expr.property, |
| 2166 | ...(alias && { alias: alias[3] }) |
| 2167 | }; |
| 2168 | } |
| 2169 | // For labels() and type() functions, maintain legacy format |
| 2170 | if (expr.type === 'FunctionCall') { |
| 2171 | const funcName = expr.name.toLowerCase(); |
| 2172 | if ((funcName === 'labels' || funcName === 'type') && |
| 2173 | expr.args.length === 1 && |
| 2174 | expr.args[0].type === 'VariableRef') { |
| 2175 | return { |
| 2176 | type: 'ReturnItem', |
| 2177 | variable: expr.args[0].variable, |
| 2178 | function: funcName, |
| 2179 | ...(alias && { alias: alias[3] }) |
| 2180 | }; |
| 2181 | } |
| 2182 | } |
| 2183 | // For complex expressions, use the expression field |
| 2184 | return { |
| 2185 | type: 'ReturnItem', |
| 2186 | expression: expr, |
| 2187 | ...(alias && { alias: alias[3] }) |
| 2188 | }; |
| 2189 | } |
| 2190 | function peg$f244() { return 'labels'; } |
| 2191 | function peg$f245() { return 'type'; } |
| 2192 | function peg$f246(orders) { |
no outgoing calls
no test coverage detected