You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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';constpath=require('path');constfs=require('fs');constparser=require('@darabonba/parser');constCppGenerator=require('@darabonba/cpp-generator');constsourceDir="<Darabonda package directory>";constoutputDir="<Generate output directory>";// generate AST data by Darabonba ParserletpackageMetaFilePath=path.join(sourceDir,'Darafile');letpackageMeta=JSON.parse(fs.readFileSync(packageMetaFilePath,'utf8'));letmainFile=path.join(sourceDir,packageMeta.main);letast=parser.parse(fs.readFileSync(mainFile,'utf8'),mainFile);// initialize generatorletgeneratorConfig={
...packageMeta,pkgDir: sourceDir,
outputDir
};letgenerator=newCppGenerator(generatorConfig);// generate cpp code by generatorgenerator.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.