Skip to content

alangpierce/decaffeinate-parser

 
 

Repository files navigation

decaffeinate-parser Build Status package version Greenkeeper badge

This project uses the official CoffeeScript parser to parse CoffeeScript source code, then maps the AST generated by the parser to one more suitable for the decaffeinate project (based on the AST generated by CoffeeScriptRedux).

This project might be useful to anyone who wants to work with a CoffeeScript AST and prefers working with a saner AST.

Install

# via yarn
$ yarn add decaffeinate-parser
# via npm
$ npm install decaffeinate-parser

Usage

This example gets the names of the parameters in the add function:

import { parse } from 'decaffeinate-parser';

let program = parse('add = (a, b) -> a + b');
let assignment = program.body.statements[0];
let fn = assignment.expression;

console.log(fn.parameters.map(param => param.data)); // [ 'a', 'b' ]

About

A better AST for CoffeeScript, inspired by CoffeeScriptRedux.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 93.2%
  • JavaScript 3.7%
  • CoffeeScript 2.8%
  • Shell 0.3%