diff --git a/bitshift/parser/__init__.py b/bitshift/parser/__init__.py index 4fea385..0c96e64 100644 --- a/bitshift/parser/__init__.py +++ b/bitshift/parser/__init__.py @@ -12,12 +12,6 @@ from .python import parse_py __all__ = ["parse", "UnsupportedFileError", "start_parse_servers"] -PARSERS = { - "Python": parse_py, - "Java": parse_via_server, - "Ruby": parse_via_server, -} - PARSER_COMMANDS = [ ('Java', ['mvn', '-f', path.join(path.dirname(__file__), "../../parsers/java/pom.xml"), @@ -120,6 +114,12 @@ def parse_via_server(codelet): codelet.symbols = symbols +PARSERS = { + "Python": parse_py, + "Java": parse_via_server, + "Ruby": parse_via_server, +} + def parse(codelet): """ Dispatches the codelet to the correct parser based on its language. @@ -132,6 +132,7 @@ def parse(codelet): :type code: Codelet """ lang = _lang(codelet) + lang_string = LANGS[lang] codelet.language = lang - if lang in PARSERS: - PARSERS[lang](codelet) + if lang_string in PARSERS: + PARSERS[lang_string](codelet) diff --git a/parsers/ruby/lib/parser.rb b/parsers/ruby/lib/parser.rb index eec293b..b2169a2 100644 --- a/parsers/ruby/lib/parser.rb +++ b/parsers/ruby/lib/parser.rb @@ -119,9 +119,11 @@ module Bitshift end def to_s - new_symbols = Hash.new {|hash, key| hash[key] = Hash.new} + new_symbols = Hash.new symbols.each do |type, sym_list| + new_symbols[type.to_s] = Hash.new + sym_list.each do |name, sym| new_symbols[type.to_s][name.to_s] = { "assignments" => sym[:assignments],