fancy 0.3.3 → 0.4.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/README.md +14 -14
- data/Rakefile +16 -4
- data/bin/fancy +3 -0
- data/bin/fspec +20 -0
- data/bin/fyi +27 -11
- data/bin/ifancy +1 -1
- data/boot/fancy_ext.rb +1 -0
- data/boot/fancy_ext/block_env.rb +1 -9
- data/boot/fancy_ext/delegator.rb +64 -0
- data/boot/fancy_ext/object.rb +4 -0
- data/boot/fancy_ext/thread.rb +4 -0
- data/boot/load.rb +5 -1
- data/boot/rbx-compiler/compiler/ast.rb +0 -1
- data/boot/rbx-compiler/compiler/ast/class_def.rb +2 -0
- data/boot/rbx-compiler/compiler/ast/method_def.rb +2 -0
- data/boot/rbx-compiler/compiler/ast/node.rb +10 -0
- data/boot/rbx-compiler/compiler/ast/ruby_args.rb +12 -0
- data/boot/rbx-compiler/compiler/ast/singleton_method_def.rb +2 -0
- data/boot/rbx-compiler/parser/fancy_parser.bundle +0 -0
- data/boot/rbx-compiler/parser/lexer.lex +5 -11
- data/boot/rbx-compiler/parser/parser.rb +16 -5
- data/boot/rbx-compiler/parser/parser.y +39 -24
- data/doc/api/fancy.css +1 -1
- data/doc/api/fancy.jsonp +1 -1
- data/doc/api/fdoc.js +22 -4
- data/doc/api/index.html +5 -6
- data/doc/api/jquery-ui.min.js +401 -0
- data/doc/api/jquery.tools.min.js +192 -0
- data/doc/api/themeswitchertool.js +250 -0
- data/doc/features.md +17 -0
- data/examples/actor_bunnies.fy +32 -0
- data/examples/actors.fy +26 -0
- data/examples/actors_primitive.fy +27 -0
- data/examples/actors_ring.fy +37 -0
- data/examples/armstrong_numbers.fy +1 -1
- data/examples/array.fy +7 -9
- data/examples/async_send.fy +1 -2
- data/examples/blocks.fy +4 -4
- data/examples/call_with_receiver.fy +1 -1
- data/examples/class.fy +1 -1
- data/examples/default_args.fy +4 -1
- data/examples/define_methods.fy +2 -2
- data/examples/echo.fy +1 -1
- data/examples/factorial.fy +1 -1
- data/examples/future_composition.fy +2 -2
- data/examples/futures.fy +0 -5
- data/examples/game_of_life.fy +1 -1
- data/examples/person.fy +1 -1
- data/lib/argv.fy +7 -2
- data/lib/array.fy +109 -42
- data/lib/block.fy +39 -14
- data/lib/boot.fy +2 -0
- data/lib/class.fy +2 -0
- data/lib/compiler/ast.fy +2 -1
- data/lib/compiler/ast/assign.fy +2 -3
- data/lib/compiler/ast/async_send.fy +1 -15
- data/lib/compiler/ast/class_def.fy +2 -1
- data/lib/compiler/ast/expression_list.fy +4 -5
- data/lib/compiler/ast/future_send.fy +1 -10
- data/lib/compiler/ast/goto.fy +46 -0
- data/lib/compiler/ast/identifier.fy +9 -7
- data/lib/compiler/ast/literals.fy +8 -1
- data/lib/compiler/ast/match.fy +14 -4
- data/lib/compiler/ast/message_send.fy +34 -6
- data/lib/compiler/ast/method_def.fy +6 -6
- data/lib/compiler/ast/node.fy +3 -3
- data/lib/compiler/ast/range.fy +1 -0
- data/lib/compiler/ast/script.fy +0 -2
- data/lib/compiler/ast/singleton_method_def.fy +2 -4
- data/lib/compiler/ast/string_interpolation.fy +17 -0
- data/lib/compiler/ast/super.fy +5 -4
- data/lib/compiler/ast/try_catch.fy +8 -6
- data/lib/compiler/ast/tuple_literal.fy +3 -2
- data/lib/compiler/command.fy +0 -1
- data/lib/compiler/compiler.fy +1 -5
- data/lib/compiler/stages.fy +6 -14
- data/lib/documentation.fy +57 -46
- data/lib/enumerable.fy +257 -23
- data/lib/enumerator.fy +122 -15
- data/lib/false_class.fy +10 -1
- data/lib/fancy_spec.fy +263 -61
- data/lib/fdoc.fy +11 -25
- data/lib/fiber.fy +11 -0
- data/lib/file.fy +8 -11
- data/lib/future.fy +84 -5
- data/lib/hash.fy +65 -14
- data/lib/integer.fy +35 -0
- data/lib/iteration.fy +54 -29
- data/lib/message.fy +6 -0
- data/lib/method.fy +0 -16
- data/lib/nil_class.fy +58 -8
- data/lib/number.fy +49 -22
- data/lib/object.fy +371 -65
- data/lib/package.fy +24 -1
- data/lib/package/installer.fy +5 -9
- data/lib/package/specification.fy +2 -2
- data/lib/parser/ext/lexer.lex +15 -11
- data/lib/parser/ext/parser.y +70 -23
- data/lib/parser/methods.fy +33 -14
- data/lib/proxy.fy +33 -3
- data/lib/range.fy +28 -0
- data/lib/rbx.fy +3 -1
- data/lib/rbx/actor.fy +53 -0
- data/lib/rbx/alpha.fy +31 -0
- data/lib/rbx/array.fy +21 -12
- data/lib/rbx/bignum.fy +6 -2
- data/lib/rbx/block.fy +23 -26
- data/lib/rbx/class.fy +54 -2
- data/lib/rbx/code_loader.fy +8 -4
- data/lib/rbx/date.fy +9 -0
- data/lib/rbx/directory.fy +18 -0
- data/lib/rbx/environment_variables.fy +1 -0
- data/lib/rbx/exception.fy +9 -2
- data/lib/rbx/fiber.fy +22 -4
- data/lib/rbx/file.fy +5 -5
- data/lib/rbx/fixnum.fy +5 -0
- data/lib/rbx/float.fy +11 -3
- data/lib/rbx/hash.fy +31 -16
- data/lib/rbx/integer.fy +1 -0
- data/lib/rbx/io.fy +17 -7
- data/lib/rbx/match_data.fy +15 -4
- data/lib/rbx/method.fy +40 -7
- data/lib/rbx/name_error.fy +4 -0
- data/lib/rbx/object.fy +92 -24
- data/lib/rbx/range.fy +20 -6
- data/lib/rbx/regexp.fy +11 -3
- data/lib/rbx/string.fy +51 -1
- data/lib/rbx/stringio.fy +17 -0
- data/lib/rbx/symbol.fy +15 -1
- data/lib/rbx/system.fy +20 -2
- data/lib/rbx/tcp_server.fy +4 -1
- data/lib/rbx/tcp_socket.fy +11 -0
- data/lib/rbx/time.fy +6 -0
- data/lib/rbx/tuple.fy +14 -5
- data/lib/set.fy +144 -29
- data/lib/stack.fy +42 -11
- data/lib/string.fy +118 -8
- data/lib/struct.fy +13 -3
- data/lib/symbol.fy +21 -2
- data/lib/thread_pool.fy +2 -1
- data/lib/true_class.fy +45 -7
- data/lib/tuple.fy +27 -9
- data/lib/version.fy +2 -2
- data/ruby_lib/fancy +43 -0
- data/ruby_lib/fdoc +23 -0
- data/ruby_lib/fspec +3 -0
- data/ruby_lib/fyi +3 -0
- data/ruby_lib/ifancy +3 -0
- data/tests/argv.fy +5 -9
- data/tests/array.fy +323 -196
- data/tests/assignment.fy +29 -29
- data/tests/block.fy +72 -59
- data/tests/class.fy +227 -138
- data/tests/control_flow.fy +83 -51
- data/tests/documentation.fy +8 -8
- data/tests/enumerable.fy +8 -0
- data/tests/enumerator.fy +47 -29
- data/tests/exception.fy +49 -32
- data/tests/file.fy +28 -28
- data/tests/fixnum.fy +170 -0
- data/tests/future.fy +24 -7
- data/tests/hash.fy +55 -38
- data/tests/method.fy +50 -43
- data/tests/nil_class.fy +37 -37
- data/tests/object.fy +152 -70
- data/tests/pattern_matching.fy +67 -31
- data/tests/range.fy +6 -6
- data/tests/set.fy +101 -4
- data/tests/stack.fy +14 -5
- data/tests/string.fy +115 -61
- data/tests/stringio.fy +18 -0
- data/tests/struct.fy +27 -0
- data/tests/symbol.fy +19 -6
- data/tests/true_class.fy +34 -34
- data/tests/tuple.fy +30 -12
- metadata +103 -81
- data/boot/rbx-compiler/compiler/ast/require.rb +0 -20
- data/examples/actor.fy +0 -37
- data/examples/curl_async.fy +0 -37
- data/lib/compiler/ast/require.fy +0 -15
- data/tests/number.fy +0 -135
- data/tests/parsing/sexp.fy +0 -50
data/README.md
CHANGED
|
@@ -3,9 +3,12 @@
|
|
|
3
3
|
(C) 2010, 2011 Christopher Bertels chris@fancy-lang.org
|
|
4
4
|
http://www.fancy-lang.org
|
|
5
5
|
|
|
6
|
+
[](http://travis-ci.org/bakkdoor/fancy)
|
|
7
|
+
|
|
8
|
+
|
|
6
9
|
----------------------------------------------------------------------
|
|
7
10
|
Fancy is a dynamic, object-oriented programming language heavily
|
|
8
|
-
inspired by Smalltalk, Ruby and Erlang. It supports dynamic code
|
|
11
|
+
inspired by Smalltalk, Ruby, Io and Erlang. It supports dynamic code
|
|
9
12
|
evaluation (as in Ruby & Smalltalk), class-based mixins, (simple)
|
|
10
13
|
pattern matching, runtime introspection & reflection, "monkey
|
|
11
14
|
patching" and much more. It runs on Rubinius, the Ruby VM, and thus
|
|
@@ -13,16 +16,19 @@ has first-class integration with Ruby's core library and any
|
|
|
13
16
|
additional Ruby libraries that run on Rubinius, including most
|
|
14
17
|
C-extensions.
|
|
15
18
|
|
|
16
|
-
It
|
|
17
|
-
futures and async
|
|
19
|
+
It supports concurrency via the actor-model, including first-class
|
|
20
|
+
futures and async message send semantics built into the language,
|
|
21
|
+
similar to Io.
|
|
18
22
|
|
|
19
23
|
For a quick feature overview, have a look at `doc/features.md`
|
|
20
|
-
For a recent version of the code with syntax highlighting look here:
|
|
21
|
-
http://fancy-lang.org/code/
|
|
22
24
|
There's also a work-in-progress tutorial/book on Fancy here:
|
|
23
25
|
https://github.com/fancy-lang/infancy
|
|
24
26
|
|
|
25
|
-
|
|
27
|
+
Fancy's standard library is all written in Fancy (with some minor
|
|
28
|
+
exceptions written in Ruby - see `boot/fancy_ext`).
|
|
29
|
+
Have a look at the `lib/` directory.
|
|
30
|
+
|
|
31
|
+
Fancy is still in development, the implementation has evolved from an
|
|
26
32
|
interpreter written in C++ to a fully bootstrapped bytecode compiler
|
|
27
33
|
for the Rubinius VM (http://www.rubini.us).
|
|
28
34
|
You can see the self-hosted compiler implementation in `lib/compiler/`.
|
|
@@ -123,7 +129,7 @@ Ruby method invocation supports passing a block variable to Ruby as a proc.
|
|
|
123
129
|
- Method & Operator calls
|
|
124
130
|
- Instance & class variable access
|
|
125
131
|
- Dynamic getter and setter method definitions (similar to Ruby's attr_acessor)
|
|
126
|
-
- Loops
|
|
132
|
+
- Loops (including `next` & `break`)
|
|
127
133
|
- Support for closures via Blocks
|
|
128
134
|
- Local & non-local returns from Blocks & Methods
|
|
129
135
|
- File reading and writing
|
|
@@ -137,17 +143,11 @@ Ruby method invocation supports passing a block variable to Ruby as a proc.
|
|
|
137
143
|
- Async message sends (`object @@ message`)
|
|
138
144
|
|
|
139
145
|
|
|
140
|
-
##What's still missing?
|
|
141
|
-
- Some concurrency stuff (e.g. language syntax for actors)
|
|
142
|
-
- Some more advanced stuff, e.g. runtime inspection of method calls
|
|
143
|
-
via MethodContext etc. (saved for later)
|
|
144
|
-
|
|
145
|
-
|
|
146
146
|
##How is it implemented?
|
|
147
147
|
- The lexer & parser are built with GNU Flex & GNU Bison.
|
|
148
148
|
And used as a Ruby c-extension from Rubinius.
|
|
149
149
|
The parser simply invokes methods on Fancy::Parser to build the AST.
|
|
150
|
-
See: `
|
|
150
|
+
See: `lib/parser/ext/parser.y` & `lib/parser/methods.fy`
|
|
151
151
|
|
|
152
152
|
- Once the AST is built, we use Rubinius' excellent compiler chain
|
|
153
153
|
to compile it to bytecode.
|
data/Rakefile
CHANGED
|
@@ -162,7 +162,7 @@ namespace :compiler do
|
|
|
162
162
|
end
|
|
163
163
|
|
|
164
164
|
task :bootstrap => ["parser:generate", "rbx_parser:ext", file(boot_parser_e)] do
|
|
165
|
-
["compiler:rootstrap", "compiler:compile", "compiler:wootstrap"
|
|
165
|
+
["compiler:rootstrap", "compiler:compile", "compiler:wootstrap"].each do |t|
|
|
166
166
|
task(t).reenable
|
|
167
167
|
task(t).execute
|
|
168
168
|
end
|
|
@@ -250,9 +250,7 @@ task :compile => compiled
|
|
|
250
250
|
|
|
251
251
|
desc "Runs the test suite."
|
|
252
252
|
task :test do
|
|
253
|
-
sh! _('bin/
|
|
254
|
-
'-e', 'ARGV rest rest each: |f| { require: f }',
|
|
255
|
-
*Dir.glob(_("tests/*.fy"))
|
|
253
|
+
sh! _('bin/fspec')
|
|
256
254
|
end
|
|
257
255
|
|
|
258
256
|
task :tests do
|
|
@@ -266,3 +264,17 @@ end
|
|
|
266
264
|
task :bootstrap => ["compiler:bootstrap"]
|
|
267
265
|
|
|
268
266
|
task :default => [:bootstrap_if_needed, :compile]
|
|
267
|
+
|
|
268
|
+
desc "Runs all example files in examples/ dir"
|
|
269
|
+
task :examples do
|
|
270
|
+
Dir.glob(_("examples/*.fy")).each do |f|
|
|
271
|
+
puts "Running #{f}"
|
|
272
|
+
puts
|
|
273
|
+
sh! _('bin/fancy'), f
|
|
274
|
+
puts
|
|
275
|
+
end
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
task "examples/" do
|
|
279
|
+
task(:examples).invoke
|
|
280
|
+
end
|
data/bin/fancy
CHANGED
data/bin/fspec
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/usr/bin/env fancy
|
|
2
|
+
|
|
3
|
+
test_dir = "tests"
|
|
4
|
+
{ test_dir = ARGV[1] } if: $ ARGV[1]
|
|
5
|
+
|
|
6
|
+
test_files = Directory list: "#{test_dir}/**/*.fy"
|
|
7
|
+
if: (test_files empty?) then: {
|
|
8
|
+
if: (Directory exists?: test_dir) then: {
|
|
9
|
+
"No test files found. Add them to the tests/ directory." println
|
|
10
|
+
} else: {
|
|
11
|
+
"No tests/ directory found. Create it!" println
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
} else: {
|
|
15
|
+
test_files each: |f| {
|
|
16
|
+
require: f
|
|
17
|
+
}
|
|
18
|
+
Console newline
|
|
19
|
+
FancySpec SpecTest print_failures
|
|
20
|
+
}
|
data/bin/fyi
CHANGED
|
@@ -2,19 +2,35 @@
|
|
|
2
2
|
# -*- fancy -*-
|
|
3
3
|
|
|
4
4
|
try {
|
|
5
|
-
if: (ARGV[1]) then:
|
|
5
|
+
if: (ARGV[1]) then: {
|
|
6
|
+
ident = ARGV rest join: " "
|
|
6
7
|
documentation = nil
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
match ident {
|
|
9
|
+
case /##/ ->
|
|
10
|
+
parts = ident split: "##"
|
|
11
|
+
obj = parts[0] eval
|
|
12
|
+
if: (parts[1]) then: |method_name| {
|
|
13
|
+
method = obj method: method_name
|
|
14
|
+
documentation = method documentation
|
|
15
|
+
}
|
|
16
|
+
case /#/ ->
|
|
17
|
+
parts = ident split: "#"
|
|
18
|
+
obj = parts[0] eval
|
|
19
|
+
if: (parts[1]) then: |method_name| {
|
|
20
|
+
method = nil
|
|
21
|
+
try {
|
|
22
|
+
method = obj instance_method: method_name
|
|
23
|
+
} catch NoMethodError {
|
|
24
|
+
# handle singleton methods if ARGV[1] is a singleton
|
|
25
|
+
method = obj method: method_name
|
|
26
|
+
}
|
|
27
|
+
documentation = method documentation
|
|
28
|
+
}
|
|
29
|
+
case _ ->
|
|
30
|
+
obj = ident eval
|
|
31
|
+
documentation = obj documentation
|
|
14
32
|
}
|
|
15
|
-
|
|
16
|
-
obj = ident eval
|
|
17
|
-
documentation = obj documentation
|
|
33
|
+
|
|
18
34
|
"Documentation for: '#{ident}':" println
|
|
19
35
|
documentation println
|
|
20
36
|
} else: {
|
data/bin/ifancy
CHANGED
data/boot/fancy_ext.rb
CHANGED
data/boot/fancy_ext/block_env.rb
CHANGED
|
@@ -6,14 +6,6 @@ class Block
|
|
|
6
6
|
alias_method :":call", :call
|
|
7
7
|
|
|
8
8
|
define_method("call:") do |args|
|
|
9
|
-
|
|
10
|
-
raise ArgumentError, "Expecting Array of arguments for Block"
|
|
11
|
-
end
|
|
12
|
-
if args.size < self.arity
|
|
13
|
-
raise ArgumentError, "Too few arguments for block: #{args.size} - Minimum of #{self.arity} expected"
|
|
14
|
-
else
|
|
15
|
-
args = args.first(self.arity) if args.size > self.arity
|
|
16
|
-
call *args
|
|
17
|
-
end
|
|
9
|
+
call *args
|
|
18
10
|
end
|
|
19
11
|
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
require "delegate"
|
|
2
|
+
|
|
3
|
+
def DelegateClass(superclass)
|
|
4
|
+
klass = Class.new
|
|
5
|
+
methods = superclass.public_instance_methods(true)
|
|
6
|
+
methods -= ::Kernel.public_instance_methods(false)
|
|
7
|
+
methods -= %w[
|
|
8
|
+
__verify_metaclass__
|
|
9
|
+
copy_from
|
|
10
|
+
singleton_class
|
|
11
|
+
to_marshal
|
|
12
|
+
]
|
|
13
|
+
methods |= ["to_s","to_a","inspect","==","=~","==="]
|
|
14
|
+
|
|
15
|
+
klass.module_eval do
|
|
16
|
+
def initialize(obj) # :nodoc:
|
|
17
|
+
@_dc_obj = obj
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def method_missing(m, *args) # :nodoc:
|
|
21
|
+
unless @_dc_obj.respond_to?(m)
|
|
22
|
+
super(m, *args)
|
|
23
|
+
end
|
|
24
|
+
@_dc_obj.__send__(m, *args)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def respond_to?(m, include_private=false) # :nodoc:
|
|
28
|
+
return true if super
|
|
29
|
+
return @_dc_obj.respond_to?(m, include_private)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def __getobj__ # :nodoc:
|
|
33
|
+
@_dc_obj
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def __setobj__(obj) # :nodoc:
|
|
37
|
+
raise ArgumentError, "cannot delegate to self" if self.equal?(obj)
|
|
38
|
+
@_dc_obj = obj
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def clone # :nodoc:
|
|
42
|
+
new = super
|
|
43
|
+
new.__setobj__(__getobj__.clone)
|
|
44
|
+
new
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def dup # :nodoc:
|
|
48
|
+
new = super
|
|
49
|
+
new.__setobj__(__getobj__.dup)
|
|
50
|
+
new
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
methods.each do |method|
|
|
55
|
+
begin
|
|
56
|
+
klass.__send__(:define_method, method) do |*args, &block|
|
|
57
|
+
@_dc_obj.__send__(method, *args, &block)
|
|
58
|
+
end
|
|
59
|
+
rescue SyntaxError
|
|
60
|
+
raise NameError, "invalid identifier #{method}"
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
return klass
|
|
64
|
+
end
|
data/boot/fancy_ext/object.rb
CHANGED
|
@@ -15,6 +15,10 @@ class Object
|
|
|
15
15
|
return self.to_s
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
+
define_method("require:") do |path|
|
|
19
|
+
Fancy::CodeLoader.send "require:", path
|
|
20
|
+
end
|
|
21
|
+
|
|
18
22
|
# HACK:
|
|
19
23
|
# When we define private/protected/public methods, we usually use
|
|
20
24
|
# Module#private, Module#protected & Module#public methods to set the
|
data/boot/load.rb
CHANGED
|
@@ -36,7 +36,11 @@ class Fancy
|
|
|
36
36
|
raise "File not found #{file}" unless File.exist?(file)
|
|
37
37
|
|
|
38
38
|
cl = Rubinius::CodeLoader.new(file)
|
|
39
|
-
|
|
39
|
+
begin
|
|
40
|
+
cm = cl.load_compiled_file(file, 0)
|
|
41
|
+
rescue ArgumentError
|
|
42
|
+
cm = cl.load_compiled_file(file, 0, 0)
|
|
43
|
+
end
|
|
40
44
|
|
|
41
45
|
source = file.sub(/\.fyc/, ".fy")
|
|
42
46
|
|
|
@@ -9,7 +9,6 @@ require base + '/ast/identifier'
|
|
|
9
9
|
require base + '/ast/string_literal'
|
|
10
10
|
require base + '/ast/method_def'
|
|
11
11
|
require base + '/ast/singleton_method_def'
|
|
12
|
-
require base + '/ast/require'
|
|
13
12
|
require base + '/ast/class_def'
|
|
14
13
|
require base + '/ast/block'
|
|
15
14
|
require base + '/ast/assign'
|
|
@@ -12,6 +12,14 @@ class Fancy
|
|
|
12
12
|
block = args.array.pop
|
|
13
13
|
block = Fancy::AST::Identifier.new(block.line, block.identifier[1..-1])
|
|
14
14
|
end
|
|
15
|
+
|
|
16
|
+
if @args.array.last.kind_of? Fancy::AST::Identifier
|
|
17
|
+
if @args.array.last.identifier =~ /^\*\w/
|
|
18
|
+
@splat = @args.array.pop()
|
|
19
|
+
@splat = Fancy::AST::Identifier.new(@splat.line, @splat.identifier[1..-1])
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
15
23
|
@block = block
|
|
16
24
|
end
|
|
17
25
|
|
|
@@ -19,6 +27,10 @@ class Fancy
|
|
|
19
27
|
@args.array.each do |a|
|
|
20
28
|
a.bytecode(g)
|
|
21
29
|
end
|
|
30
|
+
if @splat
|
|
31
|
+
@splat.bytecode(g)
|
|
32
|
+
g.cast_array
|
|
33
|
+
end
|
|
22
34
|
@block.bytecode(g) if @block
|
|
23
35
|
end
|
|
24
36
|
|
|
@@ -3,6 +3,8 @@ class Fancy
|
|
|
3
3
|
|
|
4
4
|
class SingletonMethodDef < Rubinius::AST::DefineSingleton
|
|
5
5
|
def initialize(line, obj_ident, method_ident, args, body, access = :public)
|
|
6
|
+
body = AST::ExpressionList.new(line) unless body
|
|
7
|
+
|
|
6
8
|
@line = line
|
|
7
9
|
@receiver = obj_ident
|
|
8
10
|
@name = method_ident.method_name(@receiver)
|
|
Binary file
|
|
@@ -16,7 +16,7 @@ lower [a-z]
|
|
|
16
16
|
letter [A-Za-z]
|
|
17
17
|
special [-+?!=*/^><%&~]
|
|
18
18
|
special_under ({special}|"_")
|
|
19
|
-
operator ({special}+|"||"{special_under}*)
|
|
19
|
+
operator ({special}+|" | "|"||"{special_under}*)
|
|
20
20
|
int_lit [-+]?{digit}({digit}|_{digit})*
|
|
21
21
|
double_lit {int_lit}\.{digit}+
|
|
22
22
|
hex_lit 0[xX]{hexdigit}+
|
|
@@ -38,22 +38,19 @@ thin_arrow "->"
|
|
|
38
38
|
delimiter [ \n\r\t\(\)]
|
|
39
39
|
return_local "return_local"
|
|
40
40
|
return "return"
|
|
41
|
-
require "require:"
|
|
42
41
|
try "try"
|
|
43
42
|
catch "catch"
|
|
44
43
|
finally "finally"
|
|
45
44
|
retry "retry"
|
|
46
45
|
super "super"
|
|
47
|
-
private "private"
|
|
48
|
-
protected "protected"
|
|
49
46
|
self "self"
|
|
50
47
|
match "match"
|
|
51
48
|
case "case"
|
|
52
49
|
identifier @?@?({lower}|[_&*])({letter}|{digit}|{special_under})*
|
|
53
50
|
constant {capital}({letter}|{digit}|{special_under})*
|
|
54
51
|
nested_constant ({constant}::)+{constant}
|
|
55
|
-
symbol_lit \'({identifier}|{operator}|:|"[]")+
|
|
56
|
-
ruby_send_open {identifier}{lparen}
|
|
52
|
+
symbol_lit \'({identifier}|{operator}|{constant}|:|"[]"|"|")+
|
|
53
|
+
ruby_send_open ({constant}|{identifier}){lparen}
|
|
57
54
|
ruby_oper_open {operator}{lparen}
|
|
58
55
|
regexp_lit "/".*"/"
|
|
59
56
|
comma ,
|
|
@@ -106,8 +103,8 @@ escaped_newline "\\".*\n
|
|
|
106
103
|
{rcurly} { return RCURLY; }
|
|
107
104
|
{lbracket} { return LBRACKET; }
|
|
108
105
|
{rbracket} { return RBRACKET; }
|
|
109
|
-
{lhash} { return
|
|
110
|
-
{rhash} { return
|
|
106
|
+
{lhash} { return LEFTHASH; }
|
|
107
|
+
{rhash} { return RIGHTHASH; }
|
|
111
108
|
{stab} { return STAB; }
|
|
112
109
|
{arrow} { return ARROW; }
|
|
113
110
|
{thin_arrow} { return THIN_ARROW; }
|
|
@@ -118,14 +115,11 @@ escaped_newline "\\".*\n
|
|
|
118
115
|
}
|
|
119
116
|
{return_local} { return RETURN_LOCAL; }
|
|
120
117
|
{return} { return RETURN; }
|
|
121
|
-
{require} { return REQUIRE; }
|
|
122
118
|
{try} { return TRY; }
|
|
123
119
|
{catch} { return CATCH; }
|
|
124
120
|
{finally} { return FINALLY; }
|
|
125
121
|
{retry} { return RETRY; }
|
|
126
122
|
{super} { return SUPER; }
|
|
127
|
-
{private} { return PRIVATE; }
|
|
128
|
-
{protected} { return PROTECTED; }
|
|
129
123
|
{self} {
|
|
130
124
|
yylval.object = rb_str_new2(yytext);
|
|
131
125
|
return IDENTIFIER;
|