Coder Social home page Coder Social logo

forivall / tacoscript Goto Github PK

View Code? Open in Web Editor NEW
46.0 6.0 3.0 4.28 MB

:taco: The bidirectional alt-JS language

Home Page: http://tacoscript.github.io

License: MIT License

Shell 0.44% JavaScript 99.56%
parser cst babylon javascript alt-js ast-transformations generator coffeescript

tacoscript's Introduction

Build Status Waffle.io Stories Join the chat at https://gitter.im/forivall/tacoscript

An es2015+-isomorphic altjs language, with syntax inspired by CoffeeScript, Python, Ruby, and frappe, and architecture inspired by Babel.

What does it mean that this language is "es2015+-isomorphic"?

TacoScript shares its Abstract Syntax Tree (AST) with JavaScript, using the same format as Babylon. This means that, for any valid JavaScript code, there is an exact, lossless version of that code in TacoScript, and vice versa: For all valid TacoScript code, there is an exact translated representation in JavaScript. Currently, whitespace will not always be preserved; eventually, whitespace will also be preserved.

Unlike CoffeeScript, TacoScript actually is, 100%, just JavaScript.

So, if it is just JavaScript, why does this exist? For the same reason that there are both British English and American English: Some people just prefer different conventions.

And also to experiment with new syntax that won't or can't be an ECMAScript proposal. (so Babel won't support them).

Packages

(In Progress)

Command line tools. Currently includes repl, compose, transpose, compile, and node commands.

Parses TacoScript into an AST/CST. Uses the same tree format as Babylon, deviating where necessary.

import * as horchata from "horchata"
ast = horchata.parse(code, options)

Adds CST sourceElements to an existing JavaScript / Babylon / estree CST.

(Previously tacoscript-generator)

Generates TacoScript code from a Babylon AST/CST.

import generate from "tacotruck"
code = generate(ast, options, originalSourceCode)

(Not Implemented)

Converts a JavaScript AST with CST elements to a TacoScript CST, which preserves whitespace. Inverse of alpastor.

(In progress)

Converts a TacoScript AST's CST elements to JavaScript CST elements, which then can be output as JavaScript code that preserves the whitespace present in the TacoScript code. Inverse of taqueria

AST translator (transpiler / detranspiler) core.

comal (noun) /koˈmal/ - A flat, pan-like clay or metal griddle used to cook tortillas or other foods.

tacoscript-eslint

(Not Implemented)

Transforms a TacoScript AST so that it can be checked by ESLint.

tacoscript-implicit-return-function

(In Progress, needs generator and transforms)

AST transformations for implicitly returning functions ("sharp arrows").

(In Progress, needs generator and transforms)

AST transformations for this.@ shorthand.

(In Progress, needs generator and transforms)

Parser & Generator plugins and AST transformations for and= and or=.

Could also include an acorn plugin for parsing ||= and &&= in javascript.

tacoscript-auto-const-extern

(Not Implemented)

Parser & Generator plugins for extern declarations. Required by any auto-const plugins, or if anyone creates an auto-let or CoffeeScript-style auto-var alternative plugin.

tacoscript-auto-const-statement

(Not Implemented)

AST transformations for automatic const variables when assignment is a statement. (Spec).

tacoscript-auto-const-expression-simple

(Not Implemented)

AST transformations for automatic const variables in restricted expression forms. (Spec).

tacoscript-auto-const-full

(Not Implemented)

AST transformations for automatic const variables anywhere forms. (Spec). May create ugly JavaScript code.

(In Progress, needs generator) Parser & Generator and transformations for iife's created with the with keyword syntax.

Example:

with= {bar: foo, boop: beep} > bar + boop

tacoscript-negative-conditional

(Not Implemented)

Parser & Generator plugins and AST transformations for unless and until.

tacoscript-useful-modulo

(Not Implemented)

Parser & Generator plugins and AST transformations for %%.

tacoscript-fluid-comparison

(Not Implemented)

Parser & Generator plugins and AST transformations for a < b < c, etc.

tacoscript-negative-binary-keywords

(Not Implemented)

Parser & Generator plugins and AST transformations for not instanceof, not in (, not of).

tacoscript-universal-fat-arrow

(Parsing complete, generator and transformations ready to start)

AST transformations and verification for using the fat arrow (=>) in any function definition situation, for lexical binding of this and arguments. Uses horchata's lexicallyBoundNamedFunctions feature parsing option.

tacoscript-asbool

(Not Implemented)

Parser & Generator plugins and AST transformations for !! (not not) to asbool.

tacoscript-binary-of

(Not Implemented)

Parser & Generator plugins and AST transformations for of binary operator.

tacoscript-soak

(Not Implemented)

Parser & Generator plugins and AST transformations for soak member expressions: ?. and ?[.

tacoscript-null-coalescing-op

(Not Implemented)

Parser & Generator plugins and AST transformations for the null coalescing operator: a ? b.

tacoscript-null-coalescing-assign

(Not Implemented)

Combination of tacoscript-logical-assign and tacoscript-null-coalescing-op.

tacoscript-typeof-null-is-null

(Not Implemented)

Parser & Generator plugins and AST transformations so that in TacoScript, typeof null === "null".

tacoscript-safe-switch

(Not Implemented)

Parser & Generator plugins and AST transformations for the non-fallthrough switch variant.

tacoscript-double-strudel-class-member

(Not Implemented)

Parser & Generator plugins and AST transformations for @@ shorthand operator.

tacoscript-dynamic-super

(Not Implemented)

Allow super in any (i.e. non-class) function, and translate super() to this.constructor.super_.call(this) and super.foo() to this.constructor.super_.prototype.foo.call(this)

The super_ convention is codified in util.inherits.

tacoscript-generic-template-string

(Not Implemented)

tacoscript-multiline-string

(Not Implemented)

tacoscript-multiline-regex

(Not Implemented)

tacoscript-boolean-switch-statement

(Not Implemented)

tacoscript-boolean-switch-expression

(Not Implemented)

tacoscript-auto-label

(Not Implemented)

Parser & Generator plugins and AST transformations for automatic labels for long breaks: break for, etc.

tacoscript-conditional-catch

(Not Implemented)

Parser & Generator plugins and AST transformations for conditional catch clauses.

tacoscript-rescue

(Not Implemented)

Parser & Generator plugins and AST transformations for rescue blocks for functions, for simplified error handling.

tacoscript-conditional-rescue

(Not Implemented)

Combines tacoscript-conditional-catch and tacoscript-rescue.

tacoscript-incremental-for-loop

(Not Implemented)

Parser & Generator plugins and AST transformations for upto, below, downto, above and by in for loop headers

tacoscript-literate

(Not Implemented)

Parser & Generator plugins for literate mode.

tacoscript-comprehensions

(Not Implemented)

tacoscript-ranges

(Not Implemented)

tacoscript-operator-overloading

(Not Implemented)

tacoscript-block-break

(Not Implemented)

tacoscript-variable-declaration-expressions

(Not Implemented)

tacoscript-git-magic

(Not Implemented)

Git hooks to automatically create an equivalent history in git as if a JavaScript project was written in TacoScript, and to therefore seamlessly contribute to JavaScript projects by coding in TacoScript, and vice-versa.

tacoscript's People

Contributors

amasad avatar chalbert avatar daniel15 avatar depfu[bot] avatar forbeslindesay avatar forivall avatar gitter-badger avatar gzzhanghao avatar hzoo avatar jamiebuilds avatar jmm avatar jridgewell avatar jsearles avatar kpdecker avatar loganfsmyth avatar mathiasbynens avatar mroch avatar nkzawa avatar phantom10111 avatar samwgoldman avatar sebmck avatar simeonwillbanks avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

tacoscript's Issues

Whitespace preservation

  • Create CST when parsing
  • Add CST elements to Javascript AST
  • #20 - Create tacoscript generator that is CST aware
  • #21 - Create javascript generator that is CST aware
  • Preserve CST in transforms
    • first, manually in transforms - helpers in comal-types to set CST data
    • second, automatically in comal-traverse - place whitespace from nodes removed in "replaceWith" into their replacement nodes.
  • Analyse source CST and when converting to translated CST, try to use most commonly used pattern for given node pattern

Shorthand curry for functions that matches arrows

So consider the following:

const inject = (ƒunction) => (initial) => (iterable) => reduce(ƒunction, initial, iterable)

When using functions:

function inject (ƒunction) {
  return function injectWithInitial (initial) {
    return function injectWithInitialAndIterable (iterable) {
      return reduce(ƒunction, initial, iterable)
    }
  }
}

This can get cumbersome.

With tacoscript:

function inject(ƒunction) ->
  return function injectWithInitial (initial) ->
    return function injectWithInitialAndIterable (iterable) ->
      return reduce(ƒunction, initial, iterable)

Which becomes much easier to read, however consider the following improvement:

function inject(ƒunction) -> (initial) -> (iterable) ->
  return reduce(ƒunction, initial, iterable)

Sourcemaps

  • Add tests
  • Properly pass options to comal

Harden plugin API

  • Force plugins to provide their requirements in semver, & don't load
    incompatible plugins.
    • plugins should target comal version, parser name & version and generator name & version
      • generator should also declare if it needs cst info

logical-assign: `or=`, `and=`

  • parse
  • transform
  • generate
    • expression
    • statement
  • clean up with comal-traverse Path features (.get) -- document it more.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.