Class: Xumlidot::Parsers::Generic
- Inherits:
-
MethodBasedSexpProcessor
- Object
- MethodBasedSexpProcessor
- Xumlidot::Parsers::Generic
- Defined in:
- lib/xumlidot/parsers/generic.rb
Overview
We need a level of indirection between the actual parser and MethodBasedSexpProcessor since we will probably end up inheriting from SexpProcessor directly eventually
The File processor was getting too busy and its obvious we want to share some bits of the processing
Direct Known Subclasses
Instance Attribute Summary collapse
-
#constants ⇒ Object
readonly
Returns the value of attribute constants.
Instance Method Summary collapse
-
#initialize(string, constants = Stack::Constants.new) ⇒ Generic
constructor
A new instance of Generic.
- #parse ⇒ Object
-
#process_call(exp) ⇒ Object
CALLS.
- #process_class(exp, definition_parser: ::Xumlidot::Parsers::KlassDefinition, type: Xumlidot::Types::Klass) ⇒ Object
-
#process_defn(exp, superclass_method = false) ⇒ Object
METHODS & METHOD SIGNATURES.
- #process_defs(exp) ⇒ Object
- #process_module(exp) ⇒ Object
-
#process_sclass(exp) ⇒ Object
CLASSES, MODULES AND DEFINITIONS.
Constructor Details
Instance Attribute Details
#constants ⇒ Object (readonly)
Returns the value of attribute constants.
16 17 18 |
# File 'lib/xumlidot/parsers/generic.rb', line 16 def constants @constants end |
Instance Method Details
#parse ⇒ Object
24 25 26 |
# File 'lib/xumlidot/parsers/generic.rb', line 24 def parse process(@parsed) end |
#process_call(exp) ⇒ Object
CALLS
93 94 95 96 97 98 99 100 101 102 |
# File 'lib/xumlidot/parsers/generic.rb', line 93 def process_call(exp) ::Xumlidot::Parsers::Call.new(exp, @constants.last_added) s() rescue Exception => e if ENV["XUMLIDOT_DEBUG"] STDERR.puts e.backtrace.reverse STDERR.puts "ERROR (#process_call) #{e.}" end s() end |
#process_class(exp, definition_parser: ::Xumlidot::Parsers::KlassDefinition, type: Xumlidot::Types::Klass) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/xumlidot/parsers/generic.rb', line 50 def process_class(exp, definition_parser: ::Xumlidot::Parsers::KlassDefinition, type: Xumlidot::Types::Klass) Scope.set_visibility definition = definition_parser.new(exp.dup[0..2], @class_stack).definition STDERR.puts definition.to_s if ::Xumlidot::Options.debug == true super(exp) do Scope.public do klass_or_module = type.new(definition) @constants.add(klass_or_module) process_until_empty(exp) end end rescue Exception => e if ENV["XUMLIDOT_DEBUG"] STDERR.puts e.backtrace.reverse STDERR.puts "ERROR (#process_class) #{e.}" end exp end |
#process_defn(exp, superclass_method = false) ⇒ Object
METHODS & METHOD SIGNATURES
74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/xumlidot/parsers/generic.rb', line 74 def process_defn(exp, superclass_method = false) method = ::Xumlidot::Parsers::MethodSignature.new(exp, superclass_method || @sclass.last) @constants.last_added.add_method(method) STDERR.puts method.to_s if ::Xumlidot::Options.debug == true #super(exp) { process_until_empty(exp) } # DISABLING since parsing the method is crashing s() rescue Exception => e if ENV["XUMLIDOT_DEBUG"] STDERR.puts e.backtrace.reverse STDERR.puts "ERROR (#process_def#{superclass_method ? 's' : 'n'}) #{e.}" end s() end |
#process_defs(exp) ⇒ Object
88 89 90 |
# File 'lib/xumlidot/parsers/generic.rb', line 88 def process_defs(exp) process_defn(exp, true) end |
#process_module(exp) ⇒ Object
44 45 46 47 48 |
# File 'lib/xumlidot/parsers/generic.rb', line 44 def process_module(exp) process_class(exp, definition_parser: ::Xumlidot::Parsers::ModuleDefinition, type: Xumlidot::Types::Module) end |
#process_sclass(exp) ⇒ Object
CLASSES, MODULES AND DEFINITIONS
We process the superclass differently since we dont want an actual superclass node adding - just the methods
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/xumlidot/parsers/generic.rb', line 32 def process_sclass(exp) super(exp) do Scope.public { process_until_empty(exp) } # Process the superclass with public visibility end rescue Exception => e if ENV["XUMLIDOT_DEBUG"] STDERR.puts e.backtrace.reverse STDERR.puts "ERROR (#process_sclass) #{e.}" end exp end |