diff --git a/src/main/java/org/sablecc/sablecc/parser/Parser.java b/src/main/java/org/sablecc/sablecc/parser/Parser.java index 1ab72f9d3cc73670730e705a7efbbba3247f27e3..307f9d19a936b93f4672059a32d01fefbd94b242 100644 --- a/src/main/java/org/sablecc/sablecc/parser/Parser.java +++ b/src/main/java/org/sablecc/sablecc/parser/Parser.java @@ -14,7 +14,6 @@ import java.util.ListIterator; import de.hhu.stups.sablecc.patch.IParser; import de.hhu.stups.sablecc.patch.PositionedNode; -import de.hhu.stups.sablecc.patch.SourcePosition; import org.sablecc.sablecc.lexer.Lexer; import org.sablecc.sablecc.lexer.LexerException; @@ -44,16 +43,7 @@ public class Parser implements IParser assert node.getEndPos() == null; PositionedNode beginNode = findBeginNode(beginNodeList); - if (beginNode == null) { - /* - * Sometimes (haven't found out why) we get empty list here. In - * the only observed cases we were looking for the source range - * of the whole parse unit. Then the start pos is the first char. - */ - node.setStartPos(new SourcePosition(1, 1)); - } else { - node.setStartPos(beginNode.getStartPos()); - } + node.setStartPos(beginNode.getStartPos()); PositionedNode endNode = findEndNode(endNodeList); node.setEndPos(endNode.getEndPos()); @@ -63,12 +53,7 @@ public class Parser implements IParser Object first = list.get(0); if (first instanceof List<?>) { List<?> list2 = (List<?>) first; - - if (!list2.isEmpty()) { - return (PositionedNode)list2.get(0); - } else { - return null; - } + return (PositionedNode)list2.get(0); } return (PositionedNode)first; diff --git a/src/main/resources/org/sablecc/sablecc/parser.txt b/src/main/resources/org/sablecc/sablecc/parser.txt index 7a52153a435b52057221297ce5fe3ec0728ca3d4..74b289fde1c718310093ab8549a227fa2fce7bda 100644 --- a/src/main/resources/org/sablecc/sablecc/parser.txt +++ b/src/main/resources/org/sablecc/sablecc/parser.txt @@ -22,7 +22,6 @@ import java.util.ListIterator; import de.hhu.stups.sablecc.patch.IParser; import de.hhu.stups.sablecc.patch.PositionedNode; -import de.hhu.stups.sablecc.patch.SourcePosition; import $0$lexer.Lexer; import $0$lexer.LexerException; @@ -52,16 +51,7 @@ public class Parser implements IParser assert node.getEndPos() == null; PositionedNode beginNode = findBeginNode(beginNodeList); - if (beginNode == null) { - /* - * Sometimes (haven't found out why) we get empty list here. In - * the only observed cases we were looking for the source range - * of the whole parse unit. Then the start pos is the first char. - */ - node.setStartPos(new SourcePosition(1, 1)); - } else { - node.setStartPos(beginNode.getStartPos()); - } + node.setStartPos(beginNode.getStartPos()); PositionedNode endNode = findEndNode(endNodeList); node.setEndPos(endNode.getEndPos()); @@ -71,12 +61,7 @@ public class Parser implements IParser Object first = list.get(0); if (first instanceof List<?>) { List<?> list2 = (List<?>) first; - - if (!list2.isEmpty()) { - return (PositionedNode)list2.get(0); - } else { - return null; - } + return (PositionedNode)list2.get(0); } return (PositionedNode)first;