All Projects → wolfgang42 → Rockstar Js

wolfgang42 / Rockstar Js

Licence: mit
JavaScript transpiler for the esoteric language 'Rockstar'

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Rockstar Js

Pysimpleguidesigner
Desinger for PySimpleGUI
Stars: ✭ 95 (-49.74%)
Mutual labels:  transpiler
Elixirscript
Converts Elixir to JavaScript
Stars: ✭ 1,504 (+695.77%)
Mutual labels:  transpiler
Rosid
Just-in-time development server and static site generator.
Stars: ✭ 139 (-26.46%)
Mutual labels:  transpiler
Evm2wasm
[ORPHANED] Transcompiles EVM code to eWASM
Stars: ✭ 96 (-49.21%)
Mutual labels:  transpiler
Pseudo Python
a restricted python to javascript / c# / go / ruby compiler
Stars: ✭ 106 (-43.92%)
Mutual labels:  transpiler
Ply
Painless polymorphism
Stars: ✭ 117 (-38.1%)
Mutual labels:  transpiler
Get Schwifty
Get Schwifty is a self-hosted Swift transpiler and was originally build for my WWDC scholarship application.
Stars: ✭ 89 (-52.91%)
Mutual labels:  transpiler
Aesara
Aesara is a fork of the Theano library that is maintained by the PyMC developers. It was previously named Theano-PyMC.
Stars: ✭ 145 (-23.28%)
Mutual labels:  transpiler
Godzilla
Godzilla is a ES2015 to Go source code transpiler and runtime
Stars: ✭ 1,464 (+674.6%)
Mutual labels:  transpiler
Webpack Babel Env Deps
Find dependencies to transpile with Babel.
Stars: ✭ 130 (-31.22%)
Mutual labels:  transpiler
Cs2x
Transpiles a C# subset to non .NET languages and runtimes. (Powered by Roslyn)
Stars: ✭ 97 (-48.68%)
Mutual labels:  transpiler
Babel Preset Github
GitHub.com's Babel configuration
Stars: ✭ 103 (-45.5%)
Mutual labels:  transpiler
Rbql
🦜RBQL - Rainbow Query Language: SQL-like language for (not only) CSV file processing. Supports SQL queries with Python and JavaScript expressions
Stars: ✭ 118 (-37.57%)
Mutual labels:  transpiler
Fetlang
Fetish-themed programming language
Stars: ✭ 1,337 (+607.41%)
Mutual labels:  transpiler
Swiftrewriter
A Swift Package Manager console app and library to convert Objective-C code into Swift.
Stars: ✭ 140 (-25.93%)
Mutual labels:  transpiler
Transpyle
HPC-oriented transpiler for C, C++, Cython, Fortran, OpenCL and Python.
Stars: ✭ 90 (-52.38%)
Mutual labels:  transpiler
Crossshader
⚔️ A tool for cross compiling shaders. Convert between GLSL, HLSL, Metal Shader Language, or older versions of GLSL.
Stars: ✭ 113 (-40.21%)
Mutual labels:  transpiler
C2rust
Migrate C code to Rust
Stars: ✭ 2,111 (+1016.93%)
Mutual labels:  transpiler
Rapydscript Ng
A transpiler for a Python like language to JavaScript
Stars: ✭ 140 (-25.93%)
Mutual labels:  transpiler
C2go
⚖️ A tool for transpiling C to Go.
Stars: ✭ 1,736 (+818.52%)
Mutual labels:  transpiler

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

It transpiles Rockstar code to JavaScript.

Usage:

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:

{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:

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

takes a Token like this:

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

and returns this code:

Billy="hello world!";
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].