(src: string)
| 43 | |
| 44 | /** Strip WL comments (nested), preserving newlines for cell structure. */ |
| 45 | export function stripComments(src: string): string { |
| 46 | let out = ''; |
| 47 | let depth = 0; |
| 48 | for (let i = 0; i < src.length; i++) { |
| 49 | if (src.startsWith('(*', i)) { |
| 50 | depth++; |
| 51 | i++; |
| 52 | } else if (depth > 0 && src.startsWith('*)', i)) { |
| 53 | depth--; |
| 54 | i++; |
| 55 | } else if (depth === 0) { |
| 56 | out += src[i]; |
| 57 | } else if (src[i] === '\n') { |
| 58 | out += '\n'; |
| 59 | } |
| 60 | } |
| 61 | return out; |
| 62 | } |
| 63 | |
| 64 | function asCall(expr: Json, op: string): Json[] | null { |
| 65 | return Array.isArray(expr) && expr[0] === op ? (expr as Json[]) : null; |
no outgoing calls
no test coverage detected