class Xumlidot::Parsers::Generic

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

Attributes

constants[R]

Public Class Methods

new(string, constants = Stack::Constants.new ) click to toggle source
Calls superclass method
# File lib/xumlidot/parsers/generic.rb, line 18
def initialize(string, constants = Stack::Constants.new )
  @parsed = RubyParser.new.parse(string)
  @constants = constants
  super()
end

Public Instance Methods

parse() click to toggle source
# File lib/xumlidot/parsers/generic.rb, line 24
def parse
  process(@parsed)
end
process_call(exp) click to toggle source

CALLS

# 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.message}"
  end
  s()
end
process_class(exp, definition_parser: ::Xumlidot::Parsers::KlassDefinition, type: Xumlidot::Types::Klass) click to toggle source
Calls superclass method
# 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.message}"
  end
  exp
end
process_defn(exp, superclass_method = false) click to toggle source

METHODS & METHOD SIGNATURES

# 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.message}"
  end
  s()
end
process_defs(exp) click to toggle source
# File lib/xumlidot/parsers/generic.rb, line 88
def process_defs(exp)
  process_defn(exp, true)
end
process_module(exp) click to toggle source
# 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) click to toggle source

CLASSES, MODULES AND DEFINITIONS

We process the superclass differently since we dont want an actual superclass node adding - just the methods

Calls superclass method
# 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.message}"
  end
  exp
end