poison 0.1.0.dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +22 -0
- data/README +1 -0
- data/Rakefile +58 -0
- data/bin/poison +119 -0
- data/lib/poison.rb +2 -0
- data/lib/poison/bootstrap.rb +4 -0
- data/lib/poison/bootstrap/compiler.rb +2 -0
- data/lib/poison/bootstrap/compiler/compiler.rb +46 -0
- data/lib/poison/bootstrap/compiler/grammar.rb +7095 -0
- data/lib/poison/bootstrap/compiler/node.rb +11 -0
- data/lib/poison/bootstrap/compiler/parser.rb +17 -0
- data/lib/poison/bootstrap/library.rb +1 -0
- data/lib/poison/bootstrap/library/code_loader.rb +16 -0
- data/lib/poison/bootstrap/parser.rb +0 -0
- data/lib/poison/bootstrap/syntax.rb +221 -0
- data/lib/poison/version.rb +14 -0
- data/spec/compiler/assign_spec.rb +114 -0
- data/spec/compiler/message_spec.rb +41 -0
- data/spec/compiler/value_spec.rb +57 -0
- data/spec/custom.rb +4 -0
- data/spec/custom/matchers/parse_as.rb +21 -0
- data/spec/custom/runner/relates.rb +97 -0
- data/spec/custom/utils/options.rb +21 -0
- data/spec/custom/utils/script.rb +26 -0
- data/spec/spec_helper.rb +3 -0
- metadata +94 -0
data/spec/custom.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
class ParseAsMatcher
|
2
|
+
def initialize(expected)
|
3
|
+
@expected = expected
|
4
|
+
end
|
5
|
+
|
6
|
+
def matches?(actual)
|
7
|
+
@actual = Poison::Compiler.new(actual).parse.to_sexp.last
|
8
|
+
@actual == @expected
|
9
|
+
end
|
10
|
+
|
11
|
+
def failure_message
|
12
|
+
["Expected:\n#{@actual.inspect}\n",
|
13
|
+
"to equal:\n#{@expected.inspect}"]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class Object
|
18
|
+
def parse_as(sexp)
|
19
|
+
ParseAsMatcher.new sexp
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
# NOTE: Copied from Rubinius
|
2
|
+
#
|
3
|
+
# SpecDataRelation enables concise specs that involve several different forms
|
4
|
+
# of the same data. This is specifically useful for the parser and compiler
|
5
|
+
# specs where the output of each stage is essentially related to the input
|
6
|
+
# Ruby source. Together with the #relates spec method, it enables specs like:
|
7
|
+
#
|
8
|
+
# describe "An If node" do
|
9
|
+
# relates "a if b" do
|
10
|
+
# parse do
|
11
|
+
# # return the expected sexp
|
12
|
+
# end
|
13
|
+
#
|
14
|
+
# compile do |g|
|
15
|
+
# # return the expected bytecode
|
16
|
+
# end
|
17
|
+
#
|
18
|
+
# jit do |as|
|
19
|
+
# # return the expected asm/machine code
|
20
|
+
# end
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# relates "if a; b; end" do
|
24
|
+
# # ...
|
25
|
+
# end
|
26
|
+
# end
|
27
|
+
|
28
|
+
class SpecDataRelation
|
29
|
+
# Provides a simple configurability so that any one or more of the possible
|
30
|
+
# processes can be run. See the custom options in custom/utils/options.rb.
|
31
|
+
def self.enable(process)
|
32
|
+
@processors ||= []
|
33
|
+
@processors << process
|
34
|
+
end
|
35
|
+
|
36
|
+
# Returns true if no process is specifically set or if +process+ is in the
|
37
|
+
# list of enabled processes. In other words, all processes are enabled by
|
38
|
+
# default, or any combination of them may be enabled.
|
39
|
+
def self.enabled?(process)
|
40
|
+
@processors.nil? or @processors.include?(process)
|
41
|
+
end
|
42
|
+
|
43
|
+
def initialize(ruby)
|
44
|
+
@ruby = ruby
|
45
|
+
end
|
46
|
+
|
47
|
+
# Formats the Ruby source code for reabable output in the -fs formatter
|
48
|
+
# option. If the source contains no newline characters, wraps the source in
|
49
|
+
# single quotes to set if off from the rest of the description string. If
|
50
|
+
# the source does contain newline characters, sets the indent level to four
|
51
|
+
# characters.
|
52
|
+
def format(ruby)
|
53
|
+
if /\n/ =~ ruby
|
54
|
+
lines = ruby.rstrip.to_a
|
55
|
+
if /( *)/ =~ lines.first
|
56
|
+
if $1.size > 4
|
57
|
+
dedent = $1.size - 4
|
58
|
+
ruby = lines.map { |l| l[dedent..-1] }.join
|
59
|
+
else
|
60
|
+
indent = " " * (4 - $1.size)
|
61
|
+
ruby = lines.map { |l| "#{indent}#{l}" }.join
|
62
|
+
end
|
63
|
+
end
|
64
|
+
"\n#{ruby}"
|
65
|
+
else
|
66
|
+
"'#{ruby}'"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# Creates spec example blocks if the compile process is enabled.
|
71
|
+
def compile(*plugins, &block)
|
72
|
+
return unless self.class.enabled? :compiler
|
73
|
+
|
74
|
+
ruby = @ruby
|
75
|
+
it "is compiled from #{format ruby}" do
|
76
|
+
generator = Rubinius::TestGenerator.new
|
77
|
+
generator.instance_eval(&block)
|
78
|
+
|
79
|
+
ruby.should compile_as(generator, *plugins)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def parse(&block)
|
84
|
+
return unless self.class.enabled? :parser
|
85
|
+
|
86
|
+
ruby = @ruby
|
87
|
+
it "is parsed from #{format ruby}" do
|
88
|
+
ruby.should parse_as(block.call)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
class Object
|
94
|
+
def relates(str, &block)
|
95
|
+
SpecDataRelation.new(str).instance_eval(&block)
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Custom MSpec options
|
2
|
+
#
|
3
|
+
class MSpecOptions
|
4
|
+
def compiler
|
5
|
+
# The require is inside the method because this file has to be able to be
|
6
|
+
# loaded in MRI and there are parts of the custom ensemble that are
|
7
|
+
# Rubinius specific (primarily iseq, which could potentially be fixed by
|
8
|
+
# better structuring the compiler).
|
9
|
+
require 'spec/custom/runner/relates'
|
10
|
+
|
11
|
+
on("--compiler", "Run only the compile part of the compiler specs") do
|
12
|
+
SpecDataRelation.enable :compiler
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def parser
|
17
|
+
on("--parser", "Run only the parse part of the compiler specs") do
|
18
|
+
SpecDataRelation.enable :parser
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# Custom options for mspec-run
|
2
|
+
#
|
3
|
+
class MSpecRun
|
4
|
+
def custom_options(options)
|
5
|
+
options.compiler
|
6
|
+
options.parser
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
# Custom options for mspec-ci
|
11
|
+
#
|
12
|
+
class MSpecCI
|
13
|
+
def custom_options(options)
|
14
|
+
options.compiler
|
15
|
+
options.parser
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# Custom options for mspec-tag
|
20
|
+
#
|
21
|
+
class MSpecTag
|
22
|
+
def custom_options(options)
|
23
|
+
options.compiler
|
24
|
+
options.parser
|
25
|
+
end
|
26
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: poison
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: true
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- dev
|
10
|
+
version: 0.1.0.dev
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Brian Ford
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-11-06 00:00:00 -07:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: |
|
23
|
+
Poison is a programming language based on Potion by Why The Lucky Stiff
|
24
|
+
that runs on the Rubinius VM.
|
25
|
+
|
26
|
+
email: brixen@gmail.com
|
27
|
+
executables:
|
28
|
+
- poison
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- README
|
33
|
+
- LICENSE
|
34
|
+
files:
|
35
|
+
- lib/poison/bootstrap/compiler/compiler.rb
|
36
|
+
- lib/poison/bootstrap/compiler/grammar.rb
|
37
|
+
- lib/poison/bootstrap/compiler/node.rb
|
38
|
+
- lib/poison/bootstrap/compiler/parser.rb
|
39
|
+
- lib/poison/bootstrap/compiler.rb
|
40
|
+
- lib/poison/bootstrap/library/code_loader.rb
|
41
|
+
- lib/poison/bootstrap/library.rb
|
42
|
+
- lib/poison/bootstrap/parser.rb
|
43
|
+
- lib/poison/bootstrap/syntax.rb
|
44
|
+
- lib/poison/bootstrap.rb
|
45
|
+
- lib/poison/version.rb
|
46
|
+
- lib/poison.rb
|
47
|
+
- spec/compiler/assign_spec.rb
|
48
|
+
- spec/compiler/message_spec.rb
|
49
|
+
- spec/compiler/value_spec.rb
|
50
|
+
- spec/custom/matchers/parse_as.rb
|
51
|
+
- spec/custom/runner/relates.rb
|
52
|
+
- spec/custom/utils/options.rb
|
53
|
+
- spec/custom/utils/script.rb
|
54
|
+
- spec/custom.rb
|
55
|
+
- spec/spec_helper.rb
|
56
|
+
- Rakefile
|
57
|
+
- README
|
58
|
+
- LICENSE
|
59
|
+
has_rdoc: true
|
60
|
+
homepage: http://github.com/brixen/poison
|
61
|
+
licenses: []
|
62
|
+
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options:
|
65
|
+
- --title
|
66
|
+
- Poison Gem
|
67
|
+
- --main
|
68
|
+
- README
|
69
|
+
- --line-numbers
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
segments:
|
77
|
+
- 0
|
78
|
+
version: "0"
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
segments:
|
84
|
+
- 0
|
85
|
+
version: "0"
|
86
|
+
requirements: []
|
87
|
+
|
88
|
+
rubyforge_project:
|
89
|
+
rubygems_version: 1.3.6
|
90
|
+
signing_key:
|
91
|
+
specification_version: 2
|
92
|
+
summary: Poison is an interpretation of Potion on the Rubinius VM.
|
93
|
+
test_files: []
|
94
|
+
|