🚧 Please note this project is still under heavy development. The API might be changed frequently and this doc any not be always update to date. If you get any questions, feel free to raise an issue.
We provide a compiler runs both in Node.js and modern browsers.
You can install the dependence by following command.
npm install @wenyanlang/core
const Wenyan = require('@wenyanlang/core')
// or
const { compile } = require('@wenyanlang/core')
// or
import { compile } from '@wenyanlang/core'
You can add following lind to the head of your html body.
<script src='https://unpkg.com/@wenyanlang/core/index.min.js'></script>
<script>
// scripts will be exposed to window.Wenyan
const compiled = Wenyan.compile('吾有一言。曰「「問天地好在。」」。書之。')
</script>
- core
function compile(targetLang: string, source: string, options?: CompilerOptions)
Parameters
Name | Type | Note |
---|---|---|
targetLang | string | Can be js , py or rb |
source | string | The Wenyan source code |
options | object | Compiler Options |
Fields | Default Value | Note |
---|---|---|
romanizeIdentifiers | none | Romanize variable identifiers (e.g. 甲 to JIA2 ) |
resetVarCnt | false | Reset temporary variable counter |
logCallback | console.log | Get verbose debug log |
errorLog | process.exit | Error log |