Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

creamerscript

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

creamerscript

  • 0.0.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

CreamerScript

CreamerScript is a language framework on top of Coffeescript.

Overview

CreamerScript itself is really only a Compiler. That Compiler is really just a standard way of transforming code. Sweeteners are what actually do the heavy lifting.

Process

The compilation process is done in two stages. In the first stage, it runs through all registered Sweeteners and tells them to substitute any code they will later want to transform with special tokens.

Once all chunks of code are replaced with tokens, the Compiler will iterate through those tokens, find the Sweetener responsible for it and ask it to transform it to Coffeescript. It does this recursively until all tokens are replaced with the transformed code.

Rationale

This is very much a poor man's parser approach. There is no AST and is therefor not a super robust system. You need to be able to match a chunk of code with a regexp in order to use it with CreamerScript.

The substitution phase is done depth first, meaning the inner-most entities (of nested entities) are substituted first. Strings, Arrays and Objects are all substituted first. This gets rid of a lot of the headache of dealing with nested entities.

Example

class Gear
  def constructor:chainring cog:cog
    @chainring = chainring
    @cog       = cog

  def gear_inches:diameter
    (this ratio:) / diameter

  def ratio
    @chainring / (@cog to_f)


class Wheel
  def constructor:rim tire:tire chainring:chainring cog:cog
    @rim  = rim
    @tire = tire
    @gear = (Gear new:chainring cog:cog)

  def diameter
    @rim + (@tire size)

  def gear_inches
    diameter = (this diameter:)
    (@gear gear_inches:diameter)

Usage

From the command line:

$ creamer path/to/file.creamer

From Ruby:

require "creamerscript"
compiler = Creamerscript::Compiler.new("(person say:word)")
compiler.compile
# => "person.say(word)"

FAQs

Package last updated on 07 Mar 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc