crow-cli

Transpile/compile Crystal to Flow


Keywords
crystal, flow
License
MIT
Install
npm install crow-cli@0.1.0

Documentation

Build Status Dependency Status devDependency Status

crow

crow transpiles Crystal source code to valid Flow/ES2015/JavaScript).

Code that is transpiled to valid Flow syntax may be transpiled to valid ES2015, which may be transpiled to Javascript (via Babel).

Warning: Experimental

This project is in alpha stage and should be considered highly experimental.

Installation

Via Homebrew:

brew install geppetto-apps/bin/crow

Via npm:

npm install crow-cli -g

Usage

# Compiles and outputs to foo.js.flow
$ crow foo.cr

# Same as above
$ cat foo.cr | crow > foo.js.flow

# Compile to JavaScript (via Babel)
$ npm install babel-preset-es2015 babel-plugin-transform-flow-strip-types
$ cat foo.cr | crow | babel --plugins transform-flow-strip-types --presets es2015

You can also use Docker:

$ cat foo.cr | docker run -i geppetto-apps/crow > foo.js.flow

Development

You need to have a copy of the Crystal source code sitting in a directory next to crow.

Supported AST nodes

Extracted from [Crystal's compiler][cr-parser].

  • Expressions
  • NilLiteral
  • BoolLiteral
  • NumberLiteral
  • CharLiteral
  • StringLiteral
  • StringInterpolation
  • SymbolLiteral
  • ArrayLiteral
  • HashLiteral
  • NamedTupleLiteral
  • ProcLiteral
  • RangeLiteral
  • RegexLiteral
  • TupleLiteral
  • Var
  • Block
  • Call
  • NamedArgument
  • If
  • Unless
  • IfDef
  • Assign
  • MultiAssign
  • InstanceVar
  • ReadInstanceVar
  • ClassVar
  • Global
  • BinaryOp
  • Arg
  • ProcNotation
  • Def
  • Macro
  • UnaryExpression
  • VisibilityModifier
  • IsA
  • RespondsTo
  • Require
  • When
  • Case
  • ImplicitObj
  • Path
  • While
  • Until
  • Generic
  • TypeDeclaration
  • UninitializedVar
  • Rescue
  • ExceptionHandler
  • ProcPointer
  • Union
  • Self
  • ControlExpression
  • Yield
  • Include
  • Extend
  • EnumDef
  • ClassDef
  • ModuleDef
  • LibDef
  • FunDef
  • TypeDef
  • CStructOrUnionDef
  • ExternalVar
  • Alias
  • Metaclass
  • Cast
  • NilableCast
  • TypeOf
  • Attribute
  • MacroExpression
  • MacroIf
  • MacroFor
  • MacroVar
  • MacroLiteral
  • Underscore
  • MagicConstant
  • Asm
  • AsmOperand

Contributing

  1. Fork it ( https://github.com/geppetto-apps/crow/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors