Browse Source

Remove negative line numbers for parsers.

tags/v1.0^2
Benjamin Attal 10 years ago
parent
commit
16775a6490
3 changed files with 10 additions and 8 deletions
  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 View File

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

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

else:
codelet.symbols = {}

+ 4
- 6
parsers/java/src/main/java/com/bitshift/parsing/parsers/JavaParser.java View File

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


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


if (statements.size() > 0) { if (statements.size() > 0) {
Statement last = statements.get(statements.size() - 1); Statement last = statements.get(statements.size() - 1);
@@ -89,7 +87,7 @@ public class JavaParser extends Parser {
ec = this.root.getColumnNumber(last.getStartPosition()); 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); data.put("name", name);
this._cache.push(data); this._cache.push(data);
return true; return true;
@@ -110,7 +108,7 @@ public class JavaParser extends Parser {
int sl = this.root.getLineNumber(node.getStartPosition()); int sl = this.root.getLineNumber(node.getStartPosition());
int sc = this.root.getColumnNumber(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); data.put("name", name);
this._cache.push(data); this._cache.push(data);
return true; return true;
@@ -140,7 +138,7 @@ public class JavaParser extends Parser {
int sl = this.root.getLineNumber(node.getStartPosition()); int sl = this.root.getLineNumber(node.getStartPosition());
int sc = this.root.getColumnNumber(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); this._cache.push(data);
return true; return true;
} }
@@ -161,7 +159,7 @@ public class JavaParser extends Parser {
int sl = this.root.getLineNumber(node.getStartPosition()); int sl = this.root.getLineNumber(node.getStartPosition());
int sc = this.root.getColumnNumber(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); this._cache.push(data);
return true; return true;
} }


+ 2
- 2
parsers/ruby/lib/parser.rb View File

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


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


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


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




Loading…
Cancel
Save