Skip to content

ingydotnet/pig-latin-acme

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Name

Pig::Latin - Acmeist English to Pig Latin Converter

pig-latin-acme

Synopsis

use Pig::Latin
say Pig::Latin('I love Pig Latin').convert

Run this command to watch this work in 15+ languages:

make test

Description

This is an Acmeist version of a English to Pig Latin conversion framework written in many programming languages. The languages chosen are OO in nature (or can fake it easily). The code is written as literal porting translations and does not attempt to show off any special features of a language.

The goal of this is to generate a module in many languages from one source.

One of the implementations is in Lingy, a syntaxless language that is simply an AST data structure that contains all the data necessary to generate equivalent code in many other languages. In leiu of a syntax, I use YAML to directly encode the data.

Another one of the implementations is in CafeScript, a language that is an evolution of CoffeeScript, but compiles to the Lingy AST (and thus to all the backend languages).

The overall goal of this project, is to make a proof of concept CafeScript that can generate equivalents in all the target languages and also publish finished packages to their respective CPAN (RubyGems, PyPI, NPM, etc) equivalents.

This involves not only code generation, but also test, doc and packaging tool generation.

Contributing

It is encouraged for people to port this to as many languages as makes sense. Please fork this on GitHub:

git@github.com:ingydotnet/pig-latin-acme

and send a pull request.

Here are the guidelines for contributing:

  • Add a test-<lang> rule to the Makefile

  • Add a test/test.<lang-ext> test file

  • Add a lib/Pig/Latin.<lang-ext> module file

  • Port as literally as you can

    • Code like a compiler not like a human expert

    • That said, make the code as beautiful as a great compiler could do

  • Make tests pass with make test

  • Add yourself to "Authors" section of doc/Pig/Latin.swim

    • Run make doc to regenerate the ReadMe.pod

Don't worry about getting it perfect. Your code will be reviewed and tweaked where needed/possible.

Even if your language doesn't seem like a great fit for this, try it anyway!

Language Features Exercised

Pig Latin translation was chosen because it is simple but not completely trivial. The code exercises these language features:

  • Scripts

  • Libraries

    • load, use, require

    • LIB path manipulation

    • lib/Pig/Latin.<language-extension> files

  • Classes

    • Methods

    • Construction

    • Attributes

  • Declaration

  • Assignment

  • Method calls

  • Looping/Iteration

  • Lambda Functions

  • If/Else conditionals

    • Ternary assignment

  • Strings

    • String Standard Methods

    • Substrings

    • Split

    • Concatentation

    • Interpolation

  • Arrays

    • Array Indexing

    • Array Standard Methods

  • Regular expression usage

    • Match operation

    • Capture Groups

  • Exceptions

  • I/O

    • Print to STDOUT

    • println, say, puts (adds newline)

This seems like a decent subset to get a ball rolling.

Languages Supported So Far

  • Bash

  • C++

  • CafeScript

  • CoffeeScript

  • Go

  • Lingy

  • LiveScript

  • Node.js

  • Perl 5

  • Perl 5 w/ Inline::CPP

  • Perl 6

  • PHP

  • Python (2)

  • Python 3

  • Racket

  • Ruby

  • Scala

  • Tcl

Languages Desired (Pull Requests please!)

  • C#

  • Clojure

  • D

  • Dylan

  • Eiffel

  • Erlang

  • Groovy

  • Haskell

  • Java

  • Lua

  • Objective C

  • Processing

  • Prolog

  • Scratch

  • Smalltalk

  • XSLT

Strategy

  • Hand port the module to 15 - 20 languages

    • With working tests

  • Port the CafeScript to a Lingy/YAML AST

  • Generate the target languages from the Lingy/YAML

    • Pass tests

  • Write a CafeScript compiler that can produce the YAML AST

  • Make TestML suite pass in all languages

  • Generate the language specific subdirs for packaging and release

  • Automate everything from top level Makefile

Authors

Written by:

  • Ingy döt Net <ingy@ingy.net>

  • David Oswald <davido@cpan.org>

Copyright & License

The MIT License (MIT)

Copyright 2014. Ingy döt Net.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published