diff --git a/README.md b/README.md index 236e4733959c9da26f7c7c767f80bf553382e0f6..7d9212fd45fb346c81334727a7bdb659b6d57aea 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,18 @@ SableCC 3.2 - STUPS version This work is based on SableCC 3.2 by Etienne Gagnon. Our version of SableCC enriches the abstract syntax tree with information about tokens. -Contributors to this vrsion of SableCC are: +Contributors to the extension of SableCC are: -Fabian Fritz -Marc Büngener -Jens Bendisposto +- Fabian Fritz +- Marc Büngener +- Jens Bendisposto + +The authors of the SabelCC version this work is based on are listed in the AUTHORS file. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. License --- diff --git a/build.gradle b/build.gradle index 601efb26d922518d483df6a07af2209a9562d848..6cd1db9278bc2c9aa5789311ecf13197cc8612c3 100644 --- a/build.gradle +++ b/build.gradle @@ -3,11 +3,14 @@ apply plugin: 'eclipse' apply plugin: 'maven' -project.version = '3.2.1' +project.version = '3.2.2' project.group = 'de.stups' repositories { - mavenCentral() + maven { + name "cobra" + url "http://cobra.cs.uni-duesseldorf.de/artifactory/repo" + } } dependencies { diff --git a/src/main/resources/org/sablecc/sablecc/parser.txt b/src/main/resources/org/sablecc/sablecc/parser.txt index c91e7afd2d608f43c8ffe903386501c926f8960d..51046dc8b1bbe1a73423ccf0bb059d29052f7226 100644 --- a/src/main/resources/org/sablecc/sablecc/parser.txt +++ b/src/main/resources/org/sablecc/sablecc/parser.txt @@ -55,8 +55,12 @@ public class Parser implements IParser private Map<PositionedNode, SourcecodeRange> mapping = new HashMap<PositionedNode, SourcecodeRange>(); public Map<PositionedNode, SourcecodeRange> getMapping() { return this.mapping; } + private void checkResult(Object elementToCheck) { + checkResult(elementToCheck, false); + } + @SuppressWarnings("unchecked") - private void checkResult(Object elementToCheck) { + private void checkResult(Object elementToCheck, boolean slurp) { // nodes with no tokens or sub nodes at all may exist if (this.firstPopped == null) { return; @@ -85,7 +89,7 @@ public class Parser implements IParser + elementToCheck); } - if (!this.getMapping().containsKey(elementToCheck)) { + if (!this.getMapping().containsKey(elementToCheck) || slurp ) { final PositionedNode node = (PositionedNode) elementToCheck; // dealing with a one-token element diff --git a/src/main/resources/patchfiles/SourcePosition.txt b/src/main/resources/patchfiles/SourcePosition.txt index ef6cd9cc3b3f05cb52fc05578b516a043599ef54..6521067286a3d32c1bcdddae287664fd7e81ea4e 100644 --- a/src/main/resources/patchfiles/SourcePosition.txt +++ b/src/main/resources/patchfiles/SourcePosition.txt @@ -6,7 +6,7 @@ package de.hhu.stups.sablecc.patch; -public class SourcePosition { +public class SourcePosition implements Comparable<SourcePosition> { private final int line; @@ -24,4 +24,17 @@ public class SourcePosition { public int getPos() { return pos; } + + public int compareTo(SourcePosition that) { + if (that.line < line) return 1; + if (that.line > line) return -1; + return pos-that.pos; + } + + @Override + public String toString() { + return "(" + line + "," + pos + ")"; + } + + }