Bladeren bron

Remove negative line numbers for parsers.

tags/v1.0^2
Benjamin Attal 10 jaren geleden
bovenliggende
commit
16775a6490
3 gewijzigde bestanden met toevoegingen van 10 en 8 verwijderingen
  1. +4
    -0
      bitshift/parser/__init__.py
  2. +4
    -6
      parsers/java/src/main/java/com/bitshift/parsing/parsers/JavaParser.java
  3. +2
    -2
      parsers/ruby/lib/parser.rb

+ 4
- 0
bitshift/parser/__init__.py Bestand weergeven

@@ -129,6 +129,7 @@ def parse(codelet):
lang = _lang(codelet)
lang_string = LANGS[lang]
codelet.language = lang

if lang_string in PARSERS:
symbols = PARSERS[lang_string](codelet)
symbols = {
@@ -138,3 +139,6 @@ def parse(codelet):
for name in syms]
for key, syms in symbols.iteritems()}
codelet.symbols = symbols

else:
codelet.symbols = {}

+ 4
- 6
parsers/java/src/main/java/com/bitshift/parsing/parsers/JavaParser.java Bestand weergeven

@@ -80,8 +80,6 @@ public class JavaParser extends Parser {

int sl = this.root.getLineNumber(node.getStartPosition());
int sc = this.root.getColumnNumber(node.getStartPosition());
Integer el = -1;
Integer ec = -1;

if (statements.size() > 0) {
Statement last = statements.get(statements.size() - 1);
@@ -89,7 +87,7 @@ public class JavaParser extends Parser {
ec = this.root.getColumnNumber(last.getStartPosition());
}

data.put("coord", Symbols.createCoord(sl, sc, el, ec));
data.put("coord", Symbols.createCoord(sl, sc, sl, sc));
data.put("name", name);
this._cache.push(data);
return true;
@@ -110,7 +108,7 @@ public class JavaParser extends Parser {
int sl = this.root.getLineNumber(node.getStartPosition());
int sc = this.root.getColumnNumber(node.getStartPosition());

data.put("coord", Symbols.createCoord(sl, sc, -1, -1));
data.put("coord", Symbols.createCoord(sl, sc, sl, sc));
data.put("name", name);
this._cache.push(data);
return true;
@@ -140,7 +138,7 @@ public class JavaParser extends Parser {
int sl = this.root.getLineNumber(node.getStartPosition());
int sc = this.root.getColumnNumber(node.getStartPosition());

data.put("coord", Symbols.createCoord(sl, sc, -1, -1));
data.put("coord", Symbols.createCoord(sl, sc, sl, sc));
this._cache.push(data);
return true;
}
@@ -161,7 +159,7 @@ public class JavaParser extends Parser {
int sl = this.root.getLineNumber(node.getStartPosition());
int sc = this.root.getColumnNumber(node.getStartPosition());

data.put("coord", Symbols.createCoord(sl, sc, -1, -1));
data.put("coord", Symbols.createCoord(sl, sc, sl, sc));
this._cache.push(data);
return true;
}


+ 2
- 2
parsers/ruby/lib/parser.rb Bestand weergeven

@@ -51,7 +51,7 @@ module Bitshift
break if cur_exp == nil
end

pos = [start_ln, -1, end_ln, -1]
pos = [start_ln, 1, end_ln, 1]
return pos
end

@@ -59,7 +59,7 @@ module Bitshift
pos = Hash.new
end_ln = start_ln = exp.line - offset

pos = [start_ln, -1, end_ln, -1]
pos = [start_ln, 1, end_ln, 1]
return pos
end



Laden…
Annuleren
Opslaan