From 425cb8ff1e65dcbd810d66b2a19e56738ff8c5fd Mon Sep 17 00:00:00 2001 From: Jens Bendisposto <jens@bendisposto.de> Date: Mon, 23 Apr 2012 16:42:38 +0200 Subject: [PATCH] fix for sourceposition / Empty-Production bug --- src/main/resources/org/sablecc/sablecc/parser.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/resources/org/sablecc/sablecc/parser.txt b/src/main/resources/org/sablecc/sablecc/parser.txt index 0b5109c..abccfcf 100644 --- a/src/main/resources/org/sablecc/sablecc/parser.txt +++ b/src/main/resources/org/sablecc/sablecc/parser.txt @@ -98,7 +98,8 @@ public class Parser implements IParser } final int begin = findBeginPos(this.lastPopped, node); - final int end = findEndPos(this.firstPopped); + int end = findEndPos(this.firstPopped); + if (end == -1) end = begin; final SourcecodeRange range = new SourcecodeRange(begin, end); this.getMapping().put(node, range); @@ -153,6 +154,8 @@ public class Parser implements IParser final PositionedNode node = (PositionedNode) last; final SourcecodeRange item = this.getMapping().get(node); + if (item == null) + return -1; return item.getEndIndex(); } -- GitLab