Browse Source

Ensure ruby parser returns all dictionary keys, regardless of whether or not there are elements in them.

tags/v1.0^2
Benjamin Attal 10 years ago
parent
commit
e9f0ddfe71
2 changed files with 12 additions and 9 deletions
  1. +9
    -8
      bitshift/parser/__init__.py
  2. +3
    -1
      parsers/ruby/lib/parser.rb

+ 9
- 8
bitshift/parser/__init__.py View File

@@ -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)

+ 3
- 1
parsers/ruby/lib/parser.rb View File

@@ -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],


Loading…
Cancel
Save