TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: Javascript code generation library?

3 点作者 adatta02超过 14 年前
I'm looking for a Javascript code generation library that is written in Javascript. I've used CodeModel in Java - https://codemodel.dev.java.net/ - and was hoping to find something similar (or better) for Javascript.<p>What I'm trying to do is create a visual programming environment where a user would drag and drop blocks to generate Javascript code. If anyone has used the LEGO Mindstorm IDE from a few years ago, I want to basically duplicate that but for Javascript.<p>I tried Googl'ing but the results are completely overwhelmed by SEO spam and things to generate buttons.<p>Edit: added an explanation of what I'm trying to accomplish.

2 条评论

tswicegood超过 14 年前
For those of us not familiar with CodeModel it would be more useful if we had an idea of what you're trying to do?<p>Are you looking to generate code because you want to write a DSL (or full language) and have it spit out valid JavaScript? Jison (<a href="http://zaach.github.com/jison/" rel="nofollow">http://zaach.github.com/jison/</a>) does that.<p>If you're looking for code generation just because you're coming from Java and think you need to generate code because everything is so complex and that simple tasks require 5+ classes, each implementing more interfaces than that, and… well, you're in luck. JavaScript is <i>much</i> simpler than that. Welcome to modern languages. :-)
_delirium超过 14 年前
Ometa/JS (<a href="http://www.tinlizzie.org/ometa/" rel="nofollow">http://www.tinlizzie.org/ometa/</a>) can be used for code generation, though it's fairly general rather than tailored specifically to that. It's a generalization of a PEG parser that can go the other way as well: it can match on sequences of characters to build up an AST, and can also match sequences of Javascript objects (like nested lists representing an AST) to convert them to other things. It doesn't have the big library of built-in expression types that CodeModel looks like it has, though (JForLoop, JConditional, etc.).