百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
R

rockstar-js

> 编程语言
开源

用于神秘语言"Rockstar"的 JavaScript 翻译器

199 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

用于神秘语言"Rockstar"的 JavaScript 翻译器

This is a work-in-progress implementation of the Rockstar language.

It transpiles Rockstar code to JavaScript.

Usage:

bash
yarn install
./rockstar program.rock
node program.js

Note: Due to the extremely fast speed of updates to Rockstar, this implementation may not always match the current spec. wolfgang42/rockstar has the version of this spec targeted by this implementation. View differences between the two here: wolfgang42/master...dylanbeattie/master

Also, since this is a WIP not all of Rockstar works properly yet. See the Spec Complete milestone for the list of unimplemented features.

Contributions welcome!

Design

Transpilation is broken up into three stages: parsing, block grouping, and code generation.

Parsing

First, the text of the program is parsed into statements and expressions. The resulting tokens are objects which have a t property containing the type of the token, plus other properties (generally a single mnemonic letter) with additional information about the token.

Parsing is currently implemented using PEG.js, a JS Parser Generator. I'm not entirely convinced that this was the best choice but it seems to work OK so far.

For example, the poetic string literal:

Billy says hello world!

is parsed by this expression:

PoeticString = v:Variable _ 'says' ' ' t:$[^\n]*
	{ return {t: 'Set', v: v, e: {t: 'Literal', v: t}} }

into this token:

javascript
{t: "Set", v: {t: "Variable", n: "Billy"}, e: {t: "Literal", v: "hello world!"}}

(Notice that this token contains two other tokens, v and e.)

Note for developers: After changing rockstar-parser.peg, make sure you run yarn build to regenerate the parser code.

Block grouping

The parsing step returns a series of statements, but does not know about blocks. This step (implemented by the groupBlocks function) finds statements which begin blocks (If, While, and so on) and groups the statements together inside a Block token, removing BlankLine tokens.

Code generation

This stage takes the tokens and emits JavaScript code. Each token has a function in the generators object which takes a token and returns a string. Many of these operate recursively, calling expr() on a token to generate code to be included.

For example, the Set token generator:

javascript
Set: s => `${expr(s.v)}=${expr(s.e)};`,

takes a Token like this:

javascript
{t: "Set", v: {t: "Variable", n: "Billy"}, e: {t: "Literal", v: "hello world!"}}

and returns this code:

javascript
Billy="hello world!";

Issues· 20 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

JavaScriptesoteric-languagejavascriptrockstar-programmertranspiler

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言