rubinius-melbourne 1.0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +23 -0
- data/Gemfile +4 -0
- data/LICENSE +25 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/ext/rubinius/melbourne/bstring-license.txt +29 -0
- data/ext/rubinius/melbourne/bstrlib.cpp +2687 -0
- data/ext/rubinius/melbourne/bstrlib.h +267 -0
- data/ext/rubinius/melbourne/extconf.rb +166 -0
- data/ext/rubinius/melbourne/grammar.cpp +11255 -0
- data/ext/rubinius/melbourne/grammar.hpp +11 -0
- data/ext/rubinius/melbourne/grammar.y +6063 -0
- data/ext/rubinius/melbourne/lex.c.tab +136 -0
- data/ext/rubinius/melbourne/local_state.hpp +41 -0
- data/ext/rubinius/melbourne/melbourne.cpp +60 -0
- data/ext/rubinius/melbourne/melbourne.hpp +19 -0
- data/ext/rubinius/melbourne/node.hpp +261 -0
- data/ext/rubinius/melbourne/node_types.cpp +254 -0
- data/ext/rubinius/melbourne/node_types.hpp +127 -0
- data/ext/rubinius/melbourne/node_types.rb +185 -0
- data/ext/rubinius/melbourne/parser_state.hpp +180 -0
- data/ext/rubinius/melbourne/quark.cpp +43 -0
- data/ext/rubinius/melbourne/quark.hpp +49 -0
- data/ext/rubinius/melbourne/symbols.cpp +225 -0
- data/ext/rubinius/melbourne/symbols.hpp +119 -0
- data/ext/rubinius/melbourne/var_table.cpp +81 -0
- data/ext/rubinius/melbourne/var_table.hpp +31 -0
- data/ext/rubinius/melbourne/visitor.cpp +962 -0
- data/ext/rubinius/melbourne/visitor.hpp +10 -0
- data/lib/rubinius/melbourne/version.rb +5 -0
- data/lib/rubinius/melbourne.rb +100 -0
- data/rubinius-melbourne.gemspec +25 -0
- metadata +119 -0
@@ -0,0 +1,10 @@
|
|
1
|
+
#ifndef MEL_VISITOR_HPP
|
2
|
+
#define MEL_VISITOR_HPP
|
3
|
+
|
4
|
+
namespace MELBOURNE {
|
5
|
+
void create_error(rb_parser_state *parser_state, char *msg);
|
6
|
+
NODE *parser_node_newnode(rb_parser_state*, enum node_type, VALUE, VALUE, VALUE);
|
7
|
+
VALUE process_parse_tree(rb_parser_state*, VALUE, NODE*, QUID*);
|
8
|
+
};
|
9
|
+
|
10
|
+
#endif
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require "rubinius/melbourne/melbourne"
|
2
|
+
require "rubinius/melbourne/version"
|
3
|
+
|
4
|
+
class String
|
5
|
+
def to_ast(name="(eval)", line=1)
|
6
|
+
Rubinius::ToolSet.get(:runtime)::Melbourne.parse_string self, name, line
|
7
|
+
end
|
8
|
+
|
9
|
+
def to_sexp(name="(eval)", line=1)
|
10
|
+
to_ast(name, line).to_sexp
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class File
|
15
|
+
def self.to_ast(name, line=1)
|
16
|
+
Rubinius::ToolSet.get(:runtime)::Melbourne.parse_file name, line
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.to_sexp(name, line=1)
|
20
|
+
to_ast(name, line).to_sexp
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
module Rubinius::ToolSet.current::TS
|
25
|
+
class Melbourne
|
26
|
+
attr_accessor :transforms
|
27
|
+
attr_accessor :magic_handler
|
28
|
+
attr_accessor :references
|
29
|
+
attr_reader :pre_exe
|
30
|
+
|
31
|
+
def self.parse_string(string, name="(eval)", line=1)
|
32
|
+
new(name, line).parse_string string
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.parse_file(name, line=1)
|
36
|
+
new(name, line).parse_file
|
37
|
+
end
|
38
|
+
|
39
|
+
def initialize(name, line, transforms=[])
|
40
|
+
@name = name
|
41
|
+
@line = line
|
42
|
+
@transforms = transforms
|
43
|
+
@magic_handler = nil
|
44
|
+
@data_offset = nil
|
45
|
+
@pre_exe = []
|
46
|
+
|
47
|
+
# There can be multiple reported, we need to track them all.
|
48
|
+
@syntax_errors = []
|
49
|
+
end
|
50
|
+
|
51
|
+
attr_reader :syntax_errors
|
52
|
+
|
53
|
+
def add_pre_exe(node)
|
54
|
+
@pre_exe << node if node
|
55
|
+
end
|
56
|
+
|
57
|
+
def add_magic_comment(str)
|
58
|
+
if @magic_handler
|
59
|
+
@magic_handler.add_magic_comment str
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def process_data(offset)
|
64
|
+
@data_offset = offset
|
65
|
+
end
|
66
|
+
|
67
|
+
def syntax_error
|
68
|
+
raise @syntax_errors[0] unless @syntax_errors.empty?
|
69
|
+
end
|
70
|
+
|
71
|
+
def parse_string(string)
|
72
|
+
syntax_error unless ast = string_to_ast(string, @name, @line)
|
73
|
+
ast
|
74
|
+
end
|
75
|
+
|
76
|
+
def parse_file
|
77
|
+
unless @name and File.exists? @name
|
78
|
+
raise Errno::ENOENT, @name.inspect
|
79
|
+
end
|
80
|
+
|
81
|
+
syntax_error unless ast = file_to_ast(@name, @line)
|
82
|
+
ast = AST::EndData.new @data_offset, ast if @data_offset
|
83
|
+
ast
|
84
|
+
end
|
85
|
+
|
86
|
+
def process_transforms(line, receiver, name, arguments, privately=false)
|
87
|
+
@transforms.each do |transform|
|
88
|
+
next unless transform.transform_kind == :call
|
89
|
+
|
90
|
+
if node = transform.match?(line, receiver, name, arguments, privately)
|
91
|
+
unless node.kind_of? AST::Node
|
92
|
+
node = transform.new line, receiver, name, arguments, privately
|
93
|
+
end
|
94
|
+
return node
|
95
|
+
end
|
96
|
+
end
|
97
|
+
nil
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'rubinius/toolset'
|
3
|
+
require './lib/rubinius/melbourne/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.authors = ["Brian Shirai"]
|
7
|
+
gem.email = ["brixen@gmail.com"]
|
8
|
+
gem.description = %q{Ruby parser extracted from MRI.}
|
9
|
+
gem.summary = %q{Rubinius Ruby Parser.}
|
10
|
+
gem.homepage = "https://github.com/rubinius/rubinius-melbourne"
|
11
|
+
gem.license = "BSD"
|
12
|
+
|
13
|
+
gem.files = `git ls-files`.split($\)
|
14
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
15
|
+
gem.extensions = ["ext/rubinius/melbourne/extconf.rb"]
|
16
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
17
|
+
gem.name = "rubinius-melbourne"
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
gem.version = Rubinius::ToolSet.current::TS::Melbourne::VERSION
|
20
|
+
|
21
|
+
gem.add_runtime_dependency "rubinius-toolset"
|
22
|
+
|
23
|
+
gem.add_development_dependency "mspec", "~> 1.5"
|
24
|
+
gem.add_development_dependency "rake", "~> 10.0"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rubinius-melbourne
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0.8
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brian Shirai
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-08-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rubinius-toolset
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: mspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.5'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description: Ruby parser extracted from MRI.
|
56
|
+
email:
|
57
|
+
- brixen@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions:
|
60
|
+
- ext/rubinius/melbourne/extconf.rb
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- .gitignore
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- ext/rubinius/melbourne/bstring-license.txt
|
69
|
+
- ext/rubinius/melbourne/bstrlib.cpp
|
70
|
+
- ext/rubinius/melbourne/bstrlib.h
|
71
|
+
- ext/rubinius/melbourne/extconf.rb
|
72
|
+
- ext/rubinius/melbourne/grammar.cpp
|
73
|
+
- ext/rubinius/melbourne/grammar.hpp
|
74
|
+
- ext/rubinius/melbourne/grammar.y
|
75
|
+
- ext/rubinius/melbourne/lex.c.tab
|
76
|
+
- ext/rubinius/melbourne/local_state.hpp
|
77
|
+
- ext/rubinius/melbourne/melbourne.cpp
|
78
|
+
- ext/rubinius/melbourne/melbourne.hpp
|
79
|
+
- ext/rubinius/melbourne/node.hpp
|
80
|
+
- ext/rubinius/melbourne/node_types.cpp
|
81
|
+
- ext/rubinius/melbourne/node_types.hpp
|
82
|
+
- ext/rubinius/melbourne/node_types.rb
|
83
|
+
- ext/rubinius/melbourne/parser_state.hpp
|
84
|
+
- ext/rubinius/melbourne/quark.cpp
|
85
|
+
- ext/rubinius/melbourne/quark.hpp
|
86
|
+
- ext/rubinius/melbourne/symbols.cpp
|
87
|
+
- ext/rubinius/melbourne/symbols.hpp
|
88
|
+
- ext/rubinius/melbourne/var_table.cpp
|
89
|
+
- ext/rubinius/melbourne/var_table.hpp
|
90
|
+
- ext/rubinius/melbourne/visitor.cpp
|
91
|
+
- ext/rubinius/melbourne/visitor.hpp
|
92
|
+
- lib/rubinius/melbourne.rb
|
93
|
+
- lib/rubinius/melbourne/version.rb
|
94
|
+
- rubinius-melbourne.gemspec
|
95
|
+
homepage: https://github.com/rubinius/rubinius-melbourne
|
96
|
+
licenses:
|
97
|
+
- BSD
|
98
|
+
metadata: {}
|
99
|
+
post_install_message:
|
100
|
+
rdoc_options: []
|
101
|
+
require_paths:
|
102
|
+
- lib
|
103
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - '>='
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - '>='
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
requirements: []
|
114
|
+
rubyforge_project:
|
115
|
+
rubygems_version: 2.0.7
|
116
|
+
signing_key:
|
117
|
+
specification_version: 4
|
118
|
+
summary: Rubinius Ruby Parser.
|
119
|
+
test_files: []
|