Skip to content

Commit 5217e9a

Browse files
committed
Kick it off with a bang.
0 parents  commit 5217e9a

24 files changed

+882
-0
lines changed

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*.rbc
2+
*.gem
3+
.bundle
4+
Gemfile.lock
5+
pkg/*

Gemfile

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
source "http://rubygems.org"
2+
3+
gemspec
4+
5+
gem "rake", ">= 0.8.7"
6+
gem "kpeg", "~> 0.8.2"
7+
gem "mspec", "~> 1.5.17"

LICENSE

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Copyright (c) 2011 Brian Ford. All rights reserved.
2+
3+
Permission is hereby granted, free of charge, to any person
4+
obtaining a copy of this software and associated documentation
5+
files (the "Software"), to deal in the Software without
6+
restriction, including without limitation the rights to use,
7+
copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the
9+
Software is furnished to do so, subject to the following
10+
conditions:
11+
12+
The above copyright notice and this permission notice shall be
13+
included in all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22+
OTHER DEALINGS IN THE SOFTWARE.

README

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
A native implementation of CoffeeScript [1] that runs on the Rubinius VM [2].
2+
3+
Q. Whence comes the name Poetics?
4+
A. Poetics is a partial anagram of the word CoffeeScript. It is also a nod to
5+
Jeremy Ashkenas, the author of CoffeeScript, and his interest in code as
6+
literature.
7+
8+
Q. Why a native implementation?
9+
A. CoffeeScript is an interesting language in its own right. Rather than
10+
merely being a syntax layer on top of Javascript, and bound to expressing
11+
its semantics in those of Javascript, it deserves its own implementation.
12+
Many of the reasons to use CoffeeScript in Node.js would also apply to
13+
using this native implementation.
14+
15+
16+
Installation
17+
18+
First, install Rubinius:
19+
20+
1. Using RVM (http://rvm.beginrescueend.com).
21+
22+
rvm install rbx
23+
24+
2. Or directly (http://rubini.us/doc/en/what-is-rubinius/).
25+
26+
Second, install Poetics:
27+
28+
rbx -S gem install poetics
29+
30+
31+
Running Poetics
32+
33+
Poetics provides a REPL for exploratory programming or runs CoffeeScript
34+
scripts.
35+
36+
rbx -S poetics -h
37+
38+
39+
Getting Help
40+
41+
Poetics is a work in progress. If you encounter trouble, please file an issue
42+
at https://github.com/brixen/poetics/issues
43+
44+
45+
Contributing
46+
47+
If you find Poetics interesting and would like to help out, fork the project
48+
on Github and submit a pull request.
49+
50+
51+
People
52+
53+
Poetics was created by Brian Ford (brixen) to force him to really learn
54+
Javascript and CoffeeScript.
55+
56+
<add your name here>
57+
58+
59+
License
60+
61+
Poetics is MIT licensed. See the LICENSE file.
62+
63+
64+
Credits
65+
66+
Jeremy has created an very interesting language in CoffeeScript. This
67+
implementation steals bits and pieces from other projects:
68+
69+
Rubinius (https://github.com/evanphx/rubinius/)
70+
KPeg (https://github.com/evanphx/kpeg/)
71+
Atomy (https://github.com/vito/atomy/)
72+
Poison (https://github.com/brixen/poison/)
73+
Talon (https://github.com/evanphx/talon/)
74+
75+
76+
[1] CoffeeScript (http://jashkenas.github.com/coffee-script/)
77+
[2] Rubinius (http://rubini.us)

Rakefile

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
require 'bundler'
2+
Bundler::GemHelper.install_tasks
3+
4+
task :default => :spec
5+
6+
base = File.expand_path '../lib/poetics/parser', __FILE__
7+
8+
grammar = "#{base}/poetics.kpeg"
9+
parser = "#{base}/parser.rb"
10+
11+
file parser => grammar do
12+
sh "rbx -S kpeg -f -s #{base}/poetics.kpeg -o #{base}/parser.rb"
13+
end
14+
15+
desc "Convert the grammar description to a parser"
16+
task :parser => parser
17+
18+
desc "Run the specs (default)"
19+
task :spec => :parser do
20+
sh "mspec spec"
21+
end

bin/poetics

Whitespace-only changes.

lib/poetics.rb

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
require 'poetics/version'
2+
require 'poetics/syntax'
3+
require 'poetics/parser'

lib/poetics/parser.rb

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
require 'poetics/parser/parser'
2+
3+
class Poetics::Parser
4+
include Poetics::Syntax
5+
6+
def self.parse_to_sexp(string)
7+
parser = new string
8+
unless parser.parse
9+
parser.raise_error
10+
end
11+
12+
parser.result.to_sexp
13+
end
14+
15+
attr_reader :line, :column
16+
17+
def position(line, column)
18+
@line = line
19+
@column = column
20+
end
21+
end

0 commit comments

Comments
 (0)