Skip to content

Commit

Permalink
Kick it off with a bang.
Browse files Browse the repository at this point in the history
  • Loading branch information
brixen committed May 1, 2011
0 parents commit 5217e9a
Show file tree
Hide file tree
Showing 24 changed files with 882 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
@@ -0,0 +1,5 @@
*.rbc
*.gem
.bundle
Gemfile.lock
pkg/*
7 changes: 7 additions & 0 deletions Gemfile
@@ -0,0 +1,7 @@
source "http://rubygems.org"

gemspec

gem "rake", ">= 0.8.7"
gem "kpeg", "~> 0.8.2"
gem "mspec", "~> 1.5.17"
22 changes: 22 additions & 0 deletions LICENSE
@@ -0,0 +1,22 @@
Copyright (c) 2011 Brian Ford. All rights reserved.

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
77 changes: 77 additions & 0 deletions README
@@ -0,0 +1,77 @@
A native implementation of CoffeeScript [1] that runs on the Rubinius VM [2].

Q. Whence comes the name Poetics?
A. Poetics is a partial anagram of the word CoffeeScript. It is also a nod to
Jeremy Ashkenas, the author of CoffeeScript, and his interest in code as
literature.

Q. Why a native implementation?
A. CoffeeScript is an interesting language in its own right. Rather than
merely being a syntax layer on top of Javascript, and bound to expressing
its semantics in those of Javascript, it deserves its own implementation.
Many of the reasons to use CoffeeScript in Node.js would also apply to
using this native implementation.


Installation

First, install Rubinius:

1. Using RVM (http://rvm.beginrescueend.com).

rvm install rbx

2. Or directly (http://rubini.us/doc/en/what-is-rubinius/).

Second, install Poetics:

rbx -S gem install poetics


Running Poetics

Poetics provides a REPL for exploratory programming or runs CoffeeScript
scripts.

rbx -S poetics -h


Getting Help

Poetics is a work in progress. If you encounter trouble, please file an issue
at https://github.com/brixen/poetics/issues


Contributing

If you find Poetics interesting and would like to help out, fork the project
on Github and submit a pull request.


People

Poetics was created by Brian Ford (brixen) to force him to really learn
Javascript and CoffeeScript.

<add your name here>


License

Poetics is MIT licensed. See the LICENSE file.


Credits

Jeremy has created an very interesting language in CoffeeScript. This
implementation steals bits and pieces from other projects:

Rubinius (https://github.com/evanphx/rubinius/)
KPeg (https://github.com/evanphx/kpeg/)
Atomy (https://github.com/vito/atomy/)
Poison (https://github.com/brixen/poison/)
Talon (https://github.com/evanphx/talon/)


[1] CoffeeScript (http://jashkenas.github.com/coffee-script/)
[2] Rubinius (http://rubini.us)
21 changes: 21 additions & 0 deletions Rakefile
@@ -0,0 +1,21 @@
require 'bundler'
Bundler::GemHelper.install_tasks

task :default => :spec

base = File.expand_path '../lib/poetics/parser', __FILE__

grammar = "#{base}/poetics.kpeg"
parser = "#{base}/parser.rb"

file parser => grammar do
sh "rbx -S kpeg -f -s #{base}/poetics.kpeg -o #{base}/parser.rb"
end

desc "Convert the grammar description to a parser"
task :parser => parser

desc "Run the specs (default)"
task :spec => :parser do
sh "mspec spec"
end
Empty file added bin/poetics
Empty file.
3 changes: 3 additions & 0 deletions lib/poetics.rb
@@ -0,0 +1,3 @@
require 'poetics/version'
require 'poetics/syntax'
require 'poetics/parser'
21 changes: 21 additions & 0 deletions lib/poetics/parser.rb
@@ -0,0 +1,21 @@
require 'poetics/parser/parser'

class Poetics::Parser
include Poetics::Syntax

def self.parse_to_sexp(string)
parser = new string
unless parser.parse
parser.raise_error
end

parser.result.to_sexp
end

attr_reader :line, :column

def position(line, column)
@line = line
@column = column
end
end

0 comments on commit 5217e9a

Please sign in to comment.