English | 简体中文
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/python-generator
'use strict';
const path = require('path');
const fs = require('fs');
const Generator = require('@darabonba/python-generator');
const DSL = require('@darabonba/parser');
const modulePath = '<module path>';
const moduleOutputDir = '<output dir path>';
const teaFile = fs.readFileSync(path.join(modulePath, 'Darafile'), 'utf8');
const main = fs.readFileSync(path.join(modulePath, 'main.dara'), 'utf8');
const pkgInfo = JSON.parse(teaFile);
const config = {
outputDir: moduleOutputDir,
pkgDir: modulePath,
...pkgInfo
};
// generate AST data by parser
const ast = DSL.parse(main, path.join(modulePath, 'main.dara'));
// initialize generator
const generator = new Generator(config, 'python');
generator.visit(ast);
Opening an Issue, Issues not conforming to the guidelines may be closed immediately.
Detailed changes for each release are documented in the release notes.
Apache-2.0 Copyright (c) 2009-present, Alibaba Cloud All rights reserved.