English | 简体中文
Darabonba 生成器只能在 Node.js 环境下运行。建议使用 NPM 包管理工具安装。在终端输入以下命令进行安装:
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 outputDir = '<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: outputDir,
pkgDir: modulePath,
...pkgInfo
};
const ast = DSL.parse(main, path.join(modulePath, 'main.dara'));
const generator = new Generator(config, 'python');
generator.visit(ast);
Opening an Issue,不符合指南的问题可能会立即关闭。
发布详情会更新在 release notes 文件中
Apache-2.0 Copyright (c) 2009-present, Alibaba Cloud All rights reserved.