Skip to content

Latest commit

 

History

History
71 lines (49 loc) · 1.62 KB

API.md

File metadata and controls

71 lines (49 loc) · 1.62 KB

API Specification

Back to README

🚧 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.

Installation

We provide a compiler runs both in Node.js and modern browsers.

Node.js

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'

Browsers

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>

Exposed Functions

Compile

Source

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

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