@darabonba/swift-generator

1.0.8 • Public • Published

English | 简体中文

Node.js CI codecov NPM version npm download

Darabonba Code Generator for Swift

Running Environment

  • Node.js >= 10.0

Installation

Darabonba Code Generator was designed to work in Node.js. The preferred way to install the Generator is to use the NPM package manager. Simply type the following into a terminal window:

npm install @darabonba/swift-generator

Usage

Generate Swift Code

'use strict';

const path = require('path');
const fs = require('fs');

const parser = require('@darabonba/parser');
const SwiftGenerator = require('@darabonba/swift-generator');

const sourceDir = "<Darabonda package directory>";
const outputDir = "<Generate output directory>";

// generate AST data by Darabonba Parser
let packageMetaFilePath = path.join(sourceDir, 'Darafile');
let packageMeta = JSON.parse(fs.readFileSync(packageMetaFilePath, 'utf8'));
let mainFile = path.join(sourceDir, packageMeta.main);
let ast = parser.parse(fs.readFileSync(mainFile, 'utf8'), mainFile);

// initialize generator
let generatorConfig = {
    ...packageMeta,
    pkgDir: sourceDir,
    outputDir
};

let generator = new SwiftGenerator(generatorConfig);

// generate swift code by generator
generator.visit(ast);

// The execution result will be output in the 'outputDir'

Quickly Start

git clone https://github.com/aliyun/swift-generator.git
cd swift-generator/
node examples/complex.js

Issues

Opening an Issue, Issues not conforming to the guidelines may be closed immediately.

Changelog

Detailed changes for each release are documented in the release notes.

License

Apache-2.0 Copyright (c) 2009-present, Alibaba Cloud All rights reserved.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.80latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.80
1.0.70
1.0.60
1.0.50
1.0.40
1.0.30
1.0.20
1.0.10
1.0.00

Package Sidebar

Install

npm i @darabonba/swift-generator

Weekly Downloads

0

Version

1.0.8

License

Apache-2.0

Unpacked Size

314 kB

Total Files

136

Last publish

Collaborators

  • aliyunsdkteam
  • yndu13
  • jacksontian
  • pagecao