============ empty method ============ def foo end def foo? end def foo! end --- (program (method (identifier)) (method (identifier)) (method (identifier))) ===================== method with body ===================== def foo bar end --- (program (method (identifier) (identifier))) =========================== method as attribute setter =========================== def foo= end --- (program (method (setter (identifier)))) ============================== method definition of operators ============================== def `(a) "`" end def -@(a) end def %(a) end def ..(a) end def !~(a) end --- (program (method (operator) (method_parameters (identifier)) (string)) (method (operator) (method_parameters (identifier))) (method (operator) (method_parameters (identifier))) (method (operator) (method_parameters (identifier))) (method (operator) (method_parameters (identifier)))) =================================================== method with forward slash name and regex ambiguity =================================================== puts /(/ def /(name) end def / name end --- (program (method_call (identifier) (argument_list (regex))) (method (operator) (method_parameters (identifier))) (method (operator) (method_parameters (identifier)))) =========================== method with call to super =========================== def foo super end def foo bar.baz { super } end def foo super.bar a, b end --- (program (method (identifier) (super)) (method (identifier) (method_call (call (identifier) (identifier)) (block (super)))) (method (identifier) (method_call (call (super) (identifier)) (argument_list (identifier) (identifier))))) =========================== method with args =========================== def foo(bar) end def foo(bar); end def foo(bar) end --- (program (method (identifier) (method_parameters (identifier))) (method (identifier) (method_parameters (identifier))) (method (identifier) (method_parameters (identifier)))) ================================ method with unparenthesized args ================================ def foo bar end --- (program (method (identifier) (method_parameters (identifier)))) ========================= method with multiple args ========================= def foo(bar, quux) end --- (program (method (identifier) (method_parameters (identifier) (identifier)))) ========================================= method with multiple unparenthesized args ========================================= def foo bar, quux end --- (program (method (identifier) (method_parameters (identifier) (identifier)))) ========================================= method with keyword parameters ========================================= def foo(bar: nil, baz:) end --- (program (method (identifier) (method_parameters (keyword_parameter (identifier) (nil)) (keyword_parameter (identifier))))) ========================================= method with default parameters ========================================= def foo(bar = nil) end def foo(bar=nil) end --- (program (method (identifier) (method_parameters (optional_parameter (identifier) (nil)))) (method (identifier) (method_parameters (optional_parameter (identifier) (nil))))) ========================================= method with interesting params ========================================= def foo(*options) end def foo(x, *options) end def foo(x, *options, y) end def foo(**options) end def foo(name:, **) end def foo(&block) end --- (program (method (identifier) (method_parameters (splat_parameter (identifier)))) (method (identifier) (method_parameters (identifier) (splat_parameter (identifier)))) (method (identifier) (method_parameters (identifier) (splat_parameter (identifier)) (identifier))) (method (identifier) (method_parameters (hash_splat_parameter (identifier)))) (method (identifier) (method_parameters (keyword_parameter (identifier)) (hash_splat_parameter))) (method (identifier) (method_parameters (block_parameter (identifier))))) ========================================= singleton method ========================================= def self.foo end --- (program (singleton_method (self) (identifier))) ========================================= singleton method with body ========================================= def self.foo bar end --- (program (singleton_method (self) (identifier) (identifier))) ========================================= singleton method with arg ========================================= def self.foo(bar) end --- (program (singleton_method (self) (identifier) (method_parameters (identifier)))) ========================================= singleton method with un-parenthesized arg ========================================= def self.foo bar end --- (program (singleton_method (self) (identifier) (method_parameters (identifier)))) ========================================= singleton method with args ========================================= def self.foo(bar, baz) end --- (program (singleton_method (self) (identifier) (method_parameters (identifier) (identifier)))) ========================================= singleton method with un-parenthesized args ========================================= def self.foo bar, baz end --- (program (singleton_method (self) (identifier) (method_parameters (identifier) (identifier)))) =========== empty class =========== class Foo end class Foo; end class Foo::Bar end class ::Foo::Bar end class Cß end --- (program (class (constant)) (class (constant)) (class (scope_resolution (constant) (constant))) (class (scope_resolution (scope_resolution (constant)) (constant))) (class (constant))) ============== empty subclass ============== class Foo < Bar end --- (program (class (constant) (superclass (constant)))) ================================== empty subclass of namespaced class ================================== class Foo < Bar::Quux end class Foo < ::Bar end class Foo < Bar::Baz.new(foo) end --- (program (class (constant) (superclass (scope_resolution (constant) (constant)))) (class (constant) (superclass (scope_resolution (constant)))) (class (constant) (superclass (method_call (call (scope_resolution (constant) (constant)) (identifier)) (argument_list (identifier)))))) =============== class with body =============== class Foo def bar end end --- (program (class (constant) (method (identifier)))) ========================================= class within dynamically-computed module ========================================= class foo()::Bar end --- (program (class (scope_resolution (method_call (identifier) (argument_list)) (constant)))) =============== singleton class =============== class << self end class <