1.0.7 • Published 3 years ago

@darabonba/cpp-generator v1.0.7

Weekly downloads
5
License
Apache-2.0
Repository
github
Last release
3 years ago

English | 简体中文

NPM version build status codecov David deps npm download

Darabonba Code Generator for C++

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/cpp-generator

Usage

Generate C++ Code

'use strict';

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

const parser = require('@darabonba/parser');
const CppGenerator = require('@darabonba/cpp-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 CppGenerator(generatorConfig);

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

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

Quickly Start

git clone https://github.com/aliyun/darabonba-cpp-generator.git
cd darabonba-cpp-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.

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.0

4 years ago