fancy 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (182) hide show
  1. data/README.md +14 -14
  2. data/Rakefile +16 -4
  3. data/bin/fancy +3 -0
  4. data/bin/fspec +20 -0
  5. data/bin/fyi +27 -11
  6. data/bin/ifancy +1 -1
  7. data/boot/fancy_ext.rb +1 -0
  8. data/boot/fancy_ext/block_env.rb +1 -9
  9. data/boot/fancy_ext/delegator.rb +64 -0
  10. data/boot/fancy_ext/object.rb +4 -0
  11. data/boot/fancy_ext/thread.rb +4 -0
  12. data/boot/load.rb +5 -1
  13. data/boot/rbx-compiler/compiler/ast.rb +0 -1
  14. data/boot/rbx-compiler/compiler/ast/class_def.rb +2 -0
  15. data/boot/rbx-compiler/compiler/ast/method_def.rb +2 -0
  16. data/boot/rbx-compiler/compiler/ast/node.rb +10 -0
  17. data/boot/rbx-compiler/compiler/ast/ruby_args.rb +12 -0
  18. data/boot/rbx-compiler/compiler/ast/singleton_method_def.rb +2 -0
  19. data/boot/rbx-compiler/parser/fancy_parser.bundle +0 -0
  20. data/boot/rbx-compiler/parser/lexer.lex +5 -11
  21. data/boot/rbx-compiler/parser/parser.rb +16 -5
  22. data/boot/rbx-compiler/parser/parser.y +39 -24
  23. data/doc/api/fancy.css +1 -1
  24. data/doc/api/fancy.jsonp +1 -1
  25. data/doc/api/fdoc.js +22 -4
  26. data/doc/api/index.html +5 -6
  27. data/doc/api/jquery-ui.min.js +401 -0
  28. data/doc/api/jquery.tools.min.js +192 -0
  29. data/doc/api/themeswitchertool.js +250 -0
  30. data/doc/features.md +17 -0
  31. data/examples/actor_bunnies.fy +32 -0
  32. data/examples/actors.fy +26 -0
  33. data/examples/actors_primitive.fy +27 -0
  34. data/examples/actors_ring.fy +37 -0
  35. data/examples/armstrong_numbers.fy +1 -1
  36. data/examples/array.fy +7 -9
  37. data/examples/async_send.fy +1 -2
  38. data/examples/blocks.fy +4 -4
  39. data/examples/call_with_receiver.fy +1 -1
  40. data/examples/class.fy +1 -1
  41. data/examples/default_args.fy +4 -1
  42. data/examples/define_methods.fy +2 -2
  43. data/examples/echo.fy +1 -1
  44. data/examples/factorial.fy +1 -1
  45. data/examples/future_composition.fy +2 -2
  46. data/examples/futures.fy +0 -5
  47. data/examples/game_of_life.fy +1 -1
  48. data/examples/person.fy +1 -1
  49. data/lib/argv.fy +7 -2
  50. data/lib/array.fy +109 -42
  51. data/lib/block.fy +39 -14
  52. data/lib/boot.fy +2 -0
  53. data/lib/class.fy +2 -0
  54. data/lib/compiler/ast.fy +2 -1
  55. data/lib/compiler/ast/assign.fy +2 -3
  56. data/lib/compiler/ast/async_send.fy +1 -15
  57. data/lib/compiler/ast/class_def.fy +2 -1
  58. data/lib/compiler/ast/expression_list.fy +4 -5
  59. data/lib/compiler/ast/future_send.fy +1 -10
  60. data/lib/compiler/ast/goto.fy +46 -0
  61. data/lib/compiler/ast/identifier.fy +9 -7
  62. data/lib/compiler/ast/literals.fy +8 -1
  63. data/lib/compiler/ast/match.fy +14 -4
  64. data/lib/compiler/ast/message_send.fy +34 -6
  65. data/lib/compiler/ast/method_def.fy +6 -6
  66. data/lib/compiler/ast/node.fy +3 -3
  67. data/lib/compiler/ast/range.fy +1 -0
  68. data/lib/compiler/ast/script.fy +0 -2
  69. data/lib/compiler/ast/singleton_method_def.fy +2 -4
  70. data/lib/compiler/ast/string_interpolation.fy +17 -0
  71. data/lib/compiler/ast/super.fy +5 -4
  72. data/lib/compiler/ast/try_catch.fy +8 -6
  73. data/lib/compiler/ast/tuple_literal.fy +3 -2
  74. data/lib/compiler/command.fy +0 -1
  75. data/lib/compiler/compiler.fy +1 -5
  76. data/lib/compiler/stages.fy +6 -14
  77. data/lib/documentation.fy +57 -46
  78. data/lib/enumerable.fy +257 -23
  79. data/lib/enumerator.fy +122 -15
  80. data/lib/false_class.fy +10 -1
  81. data/lib/fancy_spec.fy +263 -61
  82. data/lib/fdoc.fy +11 -25
  83. data/lib/fiber.fy +11 -0
  84. data/lib/file.fy +8 -11
  85. data/lib/future.fy +84 -5
  86. data/lib/hash.fy +65 -14
  87. data/lib/integer.fy +35 -0
  88. data/lib/iteration.fy +54 -29
  89. data/lib/message.fy +6 -0
  90. data/lib/method.fy +0 -16
  91. data/lib/nil_class.fy +58 -8
  92. data/lib/number.fy +49 -22
  93. data/lib/object.fy +371 -65
  94. data/lib/package.fy +24 -1
  95. data/lib/package/installer.fy +5 -9
  96. data/lib/package/specification.fy +2 -2
  97. data/lib/parser/ext/lexer.lex +15 -11
  98. data/lib/parser/ext/parser.y +70 -23
  99. data/lib/parser/methods.fy +33 -14
  100. data/lib/proxy.fy +33 -3
  101. data/lib/range.fy +28 -0
  102. data/lib/rbx.fy +3 -1
  103. data/lib/rbx/actor.fy +53 -0
  104. data/lib/rbx/alpha.fy +31 -0
  105. data/lib/rbx/array.fy +21 -12
  106. data/lib/rbx/bignum.fy +6 -2
  107. data/lib/rbx/block.fy +23 -26
  108. data/lib/rbx/class.fy +54 -2
  109. data/lib/rbx/code_loader.fy +8 -4
  110. data/lib/rbx/date.fy +9 -0
  111. data/lib/rbx/directory.fy +18 -0
  112. data/lib/rbx/environment_variables.fy +1 -0
  113. data/lib/rbx/exception.fy +9 -2
  114. data/lib/rbx/fiber.fy +22 -4
  115. data/lib/rbx/file.fy +5 -5
  116. data/lib/rbx/fixnum.fy +5 -0
  117. data/lib/rbx/float.fy +11 -3
  118. data/lib/rbx/hash.fy +31 -16
  119. data/lib/rbx/integer.fy +1 -0
  120. data/lib/rbx/io.fy +17 -7
  121. data/lib/rbx/match_data.fy +15 -4
  122. data/lib/rbx/method.fy +40 -7
  123. data/lib/rbx/name_error.fy +4 -0
  124. data/lib/rbx/object.fy +92 -24
  125. data/lib/rbx/range.fy +20 -6
  126. data/lib/rbx/regexp.fy +11 -3
  127. data/lib/rbx/string.fy +51 -1
  128. data/lib/rbx/stringio.fy +17 -0
  129. data/lib/rbx/symbol.fy +15 -1
  130. data/lib/rbx/system.fy +20 -2
  131. data/lib/rbx/tcp_server.fy +4 -1
  132. data/lib/rbx/tcp_socket.fy +11 -0
  133. data/lib/rbx/time.fy +6 -0
  134. data/lib/rbx/tuple.fy +14 -5
  135. data/lib/set.fy +144 -29
  136. data/lib/stack.fy +42 -11
  137. data/lib/string.fy +118 -8
  138. data/lib/struct.fy +13 -3
  139. data/lib/symbol.fy +21 -2
  140. data/lib/thread_pool.fy +2 -1
  141. data/lib/true_class.fy +45 -7
  142. data/lib/tuple.fy +27 -9
  143. data/lib/version.fy +2 -2
  144. data/ruby_lib/fancy +43 -0
  145. data/ruby_lib/fdoc +23 -0
  146. data/ruby_lib/fspec +3 -0
  147. data/ruby_lib/fyi +3 -0
  148. data/ruby_lib/ifancy +3 -0
  149. data/tests/argv.fy +5 -9
  150. data/tests/array.fy +323 -196
  151. data/tests/assignment.fy +29 -29
  152. data/tests/block.fy +72 -59
  153. data/tests/class.fy +227 -138
  154. data/tests/control_flow.fy +83 -51
  155. data/tests/documentation.fy +8 -8
  156. data/tests/enumerable.fy +8 -0
  157. data/tests/enumerator.fy +47 -29
  158. data/tests/exception.fy +49 -32
  159. data/tests/file.fy +28 -28
  160. data/tests/fixnum.fy +170 -0
  161. data/tests/future.fy +24 -7
  162. data/tests/hash.fy +55 -38
  163. data/tests/method.fy +50 -43
  164. data/tests/nil_class.fy +37 -37
  165. data/tests/object.fy +152 -70
  166. data/tests/pattern_matching.fy +67 -31
  167. data/tests/range.fy +6 -6
  168. data/tests/set.fy +101 -4
  169. data/tests/stack.fy +14 -5
  170. data/tests/string.fy +115 -61
  171. data/tests/stringio.fy +18 -0
  172. data/tests/struct.fy +27 -0
  173. data/tests/symbol.fy +19 -6
  174. data/tests/true_class.fy +34 -34
  175. data/tests/tuple.fy +30 -12
  176. metadata +103 -81
  177. data/boot/rbx-compiler/compiler/ast/require.rb +0 -20
  178. data/examples/actor.fy +0 -37
  179. data/examples/curl_async.fy +0 -37
  180. data/lib/compiler/ast/require.fy +0 -15
  181. data/tests/number.fy +0 -135
  182. 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
+ [![Build Status](https://secure.travis-ci.org/bakkdoor/fancy.png)](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 will support concurrency via the actor-model, including first-class
17
- futures and async operation semantics built into the language.
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
- It’s still in development, the implementation has evolved from an
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: `rbx/parser/parser.y` & `rbx/parser/parser.rb`
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", "compiler:compile_tests"].each do |t|
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/fancy'),
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
@@ -37,4 +37,7 @@ rescue RuntimeError => e
37
37
  else
38
38
  raise e
39
39
  end
40
+ rescue Interrupt => e
41
+ puts e
42
+ exit
40
43
  end
@@ -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: |ident| {
5
+ if: (ARGV[1]) then: {
6
+ ident = ARGV rest join: " "
6
7
  documentation = nil
7
- if: (ident includes?: "#") then: {
8
- parts = ident split: "#"
9
- obj = parts[0] eval
10
- if: (parts[1]) then: |method_name| {
11
- method = obj instance_method: $ parts[1]
12
- documentation = method documentation
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
- # just print documentation for class here
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
@@ -45,7 +45,7 @@ def save_history {
45
45
  puts("saving history")
46
46
  unless: @history_saved do: {
47
47
  File open: HISTORY_FILE modes: ['write] with: |f| {
48
- HISTORY each: |l| {
48
+ HISTORY last: 100 . each: |l| {
49
49
  f writeln: l
50
50
  }
51
51
  }
@@ -12,3 +12,4 @@ require base + "block_env"
12
12
  require base + "class"
13
13
  require base + "string_helper"
14
14
  require base + "console"
15
+ require base + "delegator"
@@ -6,14 +6,6 @@ class Block
6
6
  alias_method :":call", :call
7
7
 
8
8
  define_method("call:") do |args|
9
- unless args.is_a? Array
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
@@ -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
@@ -0,0 +1,4 @@
1
+ class Thread
2
+ alias_method :thread_local, :[]
3
+ alias_method :set_thread_local, :[]=
4
+ end
@@ -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
- cm = cl.load_compiled_file(file, 0)
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'
@@ -3,6 +3,8 @@ class Fancy
3
3
 
4
4
  class ClassDef < Rubinius::AST::Class
5
5
  def initialize(line, name, parent, body)
6
+ body = AST::ExpressionList.new(line) unless body
7
+
6
8
  if name.kind_of?(Fancy::AST::Identifier)
7
9
  name = name.name
8
10
  end
@@ -3,6 +3,8 @@ class Fancy
3
3
 
4
4
  class MethodDef < Rubinius::AST::Define
5
5
  def initialize(line, method_ident, args, body, access = :public)
6
+ body = AST::ExpressionList.new(line) unless body
7
+
6
8
  @line = line
7
9
  @name = method_ident.method_name
8
10
  @arguments = args
@@ -4,3 +4,13 @@ class Fancy
4
4
  each { |n| const_set(n, Rubinius::AST.const_get(n)) }
5
5
  end
6
6
  end
7
+
8
+ class Rubinius::AST::Self
9
+ def method_name(receiver = nil, with_ruby_args = false)
10
+ if with_ruby_args
11
+ "self".to_sym
12
+ else
13
+ ":self".to_sym
14
+ end
15
+ end
16
+ end
@@ -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)
@@ -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 LHASH; }
110
- {rhash} { return RHASH; }
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;