enso/app/gui2/parser-codegen/index.ts
Kaz Wesley 9fd1ab9092
Parser TS bindings (#7881)
Generate TS bindings and lazy deserialization for the parser types.

# Important Notes
- The new API is imported into `ffi.ts`, but not yet used.
- I have tested the generated code in isolation, but cannot commit tests as we are not currently able to load WASM modules when running in `vitest`.
2023-10-11 13:04:38 +00:00

18 lines
554 B
TypeScript

import * as fs from 'node:fs'
import * as process from 'node:process'
import * as codegen from './codegen.js'
import * as Schema from './schema.js'
const schemaPath = process.argv[2]
const outputPath = process.argv[3]
if (!schemaPath || !outputPath) {
console.error('Usage: parser-codegen <schemaPath> <outputPath>')
process.exit(1)
}
console.log(`Generating ${outputPath} from ${schemaPath}.`)
const schema: Schema.Schema = JSON.parse(fs.readFileSync(schemaPath, 'utf8'))
const code = codegen.implement(schema)
fs.writeFileSync(outputPath, code)