Commit c5781e6
committed
refactor: replace pure TS scanner with WASM-based scanner from libpg-query
Replace the custom TypeScript comment scanner with PostgreSQL's real
lexer via libpg-query's WASM _wasm_scan function. This eliminates the
risk of bugs from reimplementing PostgreSQL's lexer in TypeScript.
Key changes:
- scanner.ts now loads the WASM module directly and calls _wasm_scan
with proper JSON escaping (works around upstream bug where control
characters in token text are not escaped)
- Dependency changed from libpg-query to @libpg-query/parser (full
build with scan support)
- Unified loadModule() initializes both parse/deparse and scanner WASM
- All 36 tests passing including multi-line block comments and
dollar-quoted string handling1 parent 7fd2072 commit c5781e6
6 files changed
Lines changed: 251 additions & 156 deletions
File tree
- packages/parse
- __tests__
- src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
4 | 7 | | |
5 | 8 | | |
6 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
43 | 44 | | |
44 | | - | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
27 | 33 | | |
28 | 34 | | |
29 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
0 commit comments