@@ -16,14 +16,16 @@ import {fileURLToPath} from 'node:url';
1616import * as ohm from 'ohm-js-legacy' ;
1717import { Bench } from 'tinybench' ;
1818
19- import { Compiler } from '../src/Compiler.ts' ;
20- import { unparse , legacyGrammarToWasm } from '../test/_helpers.js' ;
19+ import { Grammar } from 'ohm-js' ;
20+ import { compileGrammars } from '../src/api.ts' ;
21+ import { unparse } from '../test/_helpers.js' ;
2122import { createReader } from '../../runtime/src/cstReader.ts' ;
2223
2324const __dirname = dirname ( fileURLToPath ( import . meta. url ) ) ;
2425const datadir = join ( __dirname , '../test/data' ) ;
2526
26- const liquid = ohm . grammars ( readFileSync ( join ( datadir , 'liquid-html.ohm' ) , 'utf8' ) ) ;
27+ const grammarSource = readFileSync ( join ( datadir , 'liquid-html.ohm' ) , 'utf8' ) ;
28+ const liquid = ohm . grammars ( grammarSource ) ;
2729
2830// Parse flags and positional args.
2931const flags = new Set ( process . argv . slice ( 2 ) . filter ( a => a . startsWith ( '--' ) ) ) ;
@@ -79,9 +81,10 @@ const pattern = positionalArgs[0];
7981
8082 // Compile to Wasm.
8183 const compileStart = bench . now ( ) ;
82- const modBytes = new Compiler ( liquid . LiquidHTML ) . compile ( ) ;
84+ const allBytes = compileGrammars ( grammarSource ) ;
8385 const compileTime = bench . now ( ) - compileStart ;
84- const g = await legacyGrammarToWasm ( liquid . LiquidHTML , { modBytes} ) ;
86+ const modBytes = allBytes . LiquidHTML ;
87+ const g = await Grammar . instantiate ( modBytes ) ;
8588 const { exports} = g . _instance ;
8689 let peakWasmHeapBytes = 0 ;
8790 let peakWasmMemoryBytes = 0 ;
0 commit comments