melbourne 1.0.0
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/HISTORY +3 -0
- data/LICENSE +27 -0
- data/README.rdoc +38 -0
- data/Rakefile +38 -0
- data/VERSION.yml +4 -0
- data/ext/melbourne/bstring-license.txt +29 -0
- data/ext/melbourne/bstrlib.c +2918 -0
- data/ext/melbourne/bstrlib.h +302 -0
- data/ext/melbourne/extconf.rb +76 -0
- data/ext/melbourne/grammar.cpp +11885 -0
- data/ext/melbourne/grammar.hpp +14 -0
- data/ext/melbourne/grammar.y +6013 -0
- data/ext/melbourne/internal.hpp +137 -0
- data/ext/melbourne/lex.c.tab +136 -0
- data/ext/melbourne/local_state.hpp +41 -0
- data/ext/melbourne/melbourne.cpp +37 -0
- data/ext/melbourne/node.hpp +262 -0
- data/ext/melbourne/node_types.cpp +245 -0
- data/ext/melbourne/node_types.hpp +135 -0
- data/ext/melbourne/node_types.rb +190 -0
- data/ext/melbourne/quark.cpp +52 -0
- data/ext/melbourne/quark.hpp +14 -0
- data/ext/melbourne/symbols.cpp +219 -0
- data/ext/melbourne/symbols.hpp +116 -0
- data/ext/melbourne/var_table.cpp +113 -0
- data/ext/melbourne/var_table.hpp +33 -0
- data/ext/melbourne/visitor.cpp +1052 -0
- data/ext/melbourne/visitor.hpp +20 -0
- data/lib/melbourne/ast/constants.rb +128 -0
- data/lib/melbourne/ast/control_flow.rb +382 -0
- data/lib/melbourne/ast/data.rb +19 -0
- data/lib/melbourne/ast/definitions.rb +561 -0
- data/lib/melbourne/ast/exceptions.rb +182 -0
- data/lib/melbourne/ast/file.rb +15 -0
- data/lib/melbourne/ast/grapher.rb +75 -0
- data/lib/melbourne/ast/literals.rb +268 -0
- data/lib/melbourne/ast/node.rb +21 -0
- data/lib/melbourne/ast/operators.rb +117 -0
- data/lib/melbourne/ast/self.rb +17 -0
- data/lib/melbourne/ast/sends.rb +451 -0
- data/lib/melbourne/ast/values.rb +74 -0
- data/lib/melbourne/ast/variables.rb +251 -0
- data/lib/melbourne/ast.rb +22 -0
- data/lib/melbourne/parser.rb +38 -0
- data/lib/melbourne/processor.rb +460 -0
- data/lib/melbourne.rb +46 -0
- data/spec/helpers/ast/node.rb +15 -0
- data/spec/helpers/ast/reduced_graph.rb +64 -0
- data/spec/lib/parser/alias_spec.rb +97 -0
- data/spec/lib/parser/and_spec.rb +63 -0
- data/spec/lib/parser/array_spec.rb +157 -0
- data/spec/lib/parser/attrasgn_spec.rb +401 -0
- data/spec/lib/parser/back_ref_spec.rb +20 -0
- data/spec/lib/parser/call_spec.rb +958 -0
- data/spec/lib/parser/case_spec.rb +577 -0
- data/spec/lib/parser/cdecl_spec.rb +108 -0
- data/spec/lib/parser/class_spec.rb +221 -0
- data/spec/lib/parser/colon2_spec.rb +13 -0
- data/spec/lib/parser/colon3_spec.rb +12 -0
- data/spec/lib/parser/const_spec.rb +12 -0
- data/spec/lib/parser/cvar_spec.rb +55 -0
- data/spec/lib/parser/cvasgn_spec.rb +71 -0
- data/spec/lib/parser/cvdecl_spec.rb +31 -0
- data/spec/lib/parser/defined_spec.rb +353 -0
- data/spec/lib/parser/defn_spec.rb +1409 -0
- data/spec/lib/parser/defs_spec.rb +247 -0
- data/spec/lib/parser/dot2_spec.rb +29 -0
- data/spec/lib/parser/dot3_spec.rb +29 -0
- data/spec/lib/parser/dregx_spec.rb +127 -0
- data/spec/lib/parser/dstr_spec.rb +453 -0
- data/spec/lib/parser/dsym_spec.rb +31 -0
- data/spec/lib/parser/dxstr_spec.rb +31 -0
- data/spec/lib/parser/ensure_spec.rb +279 -0
- data/spec/lib/parser/false_spec.rb +12 -0
- data/spec/lib/parser/flip2_spec.rb +138 -0
- data/spec/lib/parser/flip3_spec.rb +100 -0
- data/spec/lib/parser/for_spec.rb +279 -0
- data/spec/lib/parser/gasgn_spec.rb +34 -0
- data/spec/lib/parser/gvar_spec.rb +33 -0
- data/spec/lib/parser/hash_spec.rb +77 -0
- data/spec/lib/parser/iasgn_spec.rb +54 -0
- data/spec/lib/parser/if_spec.rb +439 -0
- data/spec/lib/parser/iter_spec.rb +2582 -0
- data/spec/lib/parser/lasgn_spec.rb +1066 -0
- data/spec/lib/parser/lit_spec.rb +75 -0
- data/spec/lib/parser/masgn_spec.rb +1970 -0
- data/spec/lib/parser/match2_spec.rb +47 -0
- data/spec/lib/parser/match3_spec.rb +54 -0
- data/spec/lib/parser/match_spec.rb +19 -0
- data/spec/lib/parser/module_spec.rb +102 -0
- data/spec/lib/parser/nil_spec.rb +13 -0
- data/spec/lib/parser/not_spec.rb +39 -0
- data/spec/lib/parser/nth_ref_spec.rb +12 -0
- data/spec/lib/parser/op_asgn_spec.rb +619 -0
- data/spec/lib/parser/or_spec.rb +155 -0
- data/spec/lib/parser/postexe_spec.rb +31 -0
- data/spec/lib/parser/regex_spec.rb +52 -0
- data/spec/lib/parser/rescue_spec.rb +1028 -0
- data/spec/lib/parser/return_spec.rb +151 -0
- data/spec/lib/parser/sclass_spec.rb +172 -0
- data/spec/lib/parser/str_spec.rb +162 -0
- data/spec/lib/parser/super_spec.rb +276 -0
- data/spec/lib/parser/true_spec.rb +12 -0
- data/spec/lib/parser/undef_spec.rb +222 -0
- data/spec/lib/parser/until_spec.rb +286 -0
- data/spec/lib/parser/valias_spec.rb +12 -0
- data/spec/lib/parser/while_spec.rb +458 -0
- data/spec/lib/parser/xstr_spec.rb +12 -0
- data/spec/lib/parser/yield_spec.rb +202 -0
- data/spec/lib/parser/zsuper_spec.rb +101 -0
- data/spec/matchers/parse_as.rb +27 -0
- data/spec/spec_helper.rb +10 -0
- metadata +168 -0
data/HISTORY
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Copyright (c) 2007, Evan Phoenix
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
The gem is provided by Marco Otte-Witte.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
* Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
* Redistributions in binary form must reproduce the above copyright notice
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
* Neither the name of the Evan Phoenix nor the names of its contributors
|
|
15
|
+
may be used to endorse or promote products derived from this software
|
|
16
|
+
without specific prior written permission.
|
|
17
|
+
|
|
18
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
19
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
20
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
21
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
|
22
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
23
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
24
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
25
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
26
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
27
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.rdoc
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
= Melbourne
|
|
2
|
+
|
|
3
|
+
Melbourne is Rubinius[http://rubini.us]' parser component. The +melbourne+ gem extracts
|
|
4
|
+
this parser component for stand-alone use under MRI and other environments.
|
|
5
|
+
|
|
6
|
+
For Melbourne's full RDoc, see {rdoc.info}[http://rdoc.info/projects/marcoow/melbourne].
|
|
7
|
+
|
|
8
|
+
== Usage
|
|
9
|
+
|
|
10
|
+
Melbourne generates abstract syntax trees (ASTs) from Ruby source code:
|
|
11
|
+
|
|
12
|
+
require 'melbourne'
|
|
13
|
+
|
|
14
|
+
'class Test; end'.to_ast # => <AST::Class:0x1017800f8
|
|
15
|
+
@line=1,
|
|
16
|
+
@body=#<AST::EmptyBody:0x101780058 @line=1>,
|
|
17
|
+
@name=#<AST::ClassName:0x101780080 @line=1, @superclass=#<AST::Nil:0x1017800a8 @line=1>, @name=:Test>,
|
|
18
|
+
@superclass=#<AST::Nil:0x1017800a8 @line=1>>
|
|
19
|
+
|
|
20
|
+
== Abstract Syntax Trees
|
|
21
|
+
|
|
22
|
+
Abstract syntax trees allow for deep introspection of Ruby source code and are far
|
|
23
|
+
easier to handle than e.g. S-expressions as provided by ParseTree[http://parsetree.rubyforge.org/]
|
|
24
|
+
and other gems.
|
|
25
|
+
|
|
26
|
+
For more information on abstract syntax trees, see Wikipedia[http://en.wikipedia.org/wiki/Abstract_syntax_trees].
|
|
27
|
+
|
|
28
|
+
== Authors
|
|
29
|
+
|
|
30
|
+
The original code of Melbourne is part of the {Rubinius project}[http://rubini.us/] and
|
|
31
|
+
was written by and is © Evan Phoenix[http://github.com/evanphx/].
|
|
32
|
+
|
|
33
|
+
Melbourne was extracted from Rubinius into this gem by Marco Otte-Witte[http://simplabs.com].
|
|
34
|
+
|
|
35
|
+
== Bugs/ Feature Requests
|
|
36
|
+
|
|
37
|
+
the +melbourne+ gem is <b>not</b> maintained by the Rubinius[http://rubini.us] team! If you encounter
|
|
38
|
+
bugs or have feature requests, refer to the {Github repository}[http://github.com/marcoow/melbourne/issues].
|
data/Rakefile
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
require 'rake'
|
|
2
|
+
require 'rake/rdoctask'
|
|
3
|
+
require 'spec/rake/spectask'
|
|
4
|
+
|
|
5
|
+
desc 'Default: run specs.'
|
|
6
|
+
task :default => :spec
|
|
7
|
+
|
|
8
|
+
desc 'Run the specs.'
|
|
9
|
+
Spec::Rake::SpecTask.new(:spec) do |t|
|
|
10
|
+
t.spec_opts << '--color'
|
|
11
|
+
t.spec_opts << '--format=html:doc/spec.html'
|
|
12
|
+
t.spec_opts << '--format=specdoc'
|
|
13
|
+
t.rcov_opts << '--exclude "gems/*,spec/*,init.rb"'
|
|
14
|
+
t.rcov = true
|
|
15
|
+
t.rcov_dir = 'doc/coverage'
|
|
16
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
desc 'Generate documentation for the Melbourne gem.'
|
|
20
|
+
Rake::RDocTask.new(:rdoc) do |t|
|
|
21
|
+
t.rdoc_dir = 'doc'
|
|
22
|
+
t.title = 'Melbourne'
|
|
23
|
+
t.options << '--line-numbers' << '--inline-source'
|
|
24
|
+
t.rdoc_files.include('README.rdoc')
|
|
25
|
+
t.rdoc_files.include('lib/**/*.rb')
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
begin
|
|
29
|
+
require 'simplabs/excellent/rake'
|
|
30
|
+
|
|
31
|
+
desc 'Analyse the Melbourne source with Excellent.'
|
|
32
|
+
Simplabs::Excellent::Rake::ExcellentTask.new(:excellent) do |t|
|
|
33
|
+
t.html = 'doc/excellent.html'
|
|
34
|
+
t.paths = ['lib']
|
|
35
|
+
end
|
|
36
|
+
rescue LoadError
|
|
37
|
+
puts "Install the excellent gem for source code analysis."
|
|
38
|
+
end
|
data/VERSION.yml
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Copyright (c) 2002-2007 Paul Hsieh
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
|
6
|
+
|
|
7
|
+
Redistributions of source code must retain the above copyright notice,
|
|
8
|
+
this list of conditions and the following disclaimer.
|
|
9
|
+
|
|
10
|
+
Redistributions in binary form must reproduce the above copyright notice,
|
|
11
|
+
this list of conditions and the following disclaimer in the documentation
|
|
12
|
+
and/or other materials provided with the distribution.
|
|
13
|
+
|
|
14
|
+
Neither the name of bstrlib nor the names of its contributors may be used
|
|
15
|
+
to endorse or promote products derived from this software without
|
|
16
|
+
specific prior written permission.
|
|
17
|
+
|
|
18
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
19
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
20
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
21
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
22
|
+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
23
|
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
24
|
+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
25
|
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
26
|
+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
27
|
+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
28
|
+
POSSIBILITY OF SUCH DAMAGE.
|
|
29
|
+
|