Skip to content

Commit

Permalink
Pseudo-Merge fd2ece2 avoid confusing lgtm.com
Browse files Browse the repository at this point in the history
commit fd2ece2
Author:     Gerwin Klein <gerwin.klein@data61.csiro.au>
AuthorDate: Sun Dec 8 11:32:08 2019 +1030
Commit:     Gerwin Klein <lsf37@doclsf.de>
CommitDate: Sun Dec 8 12:12:32 2019 +1030

    avoid confusing lgtm.com

Updated from target/jflex-parent-1.8.0-SNAPSHOT-sources.jar
  • Loading branch information
traviscibot committed Dec 8, 2019
1 parent 45a9e59 commit 3ca3c87
Show file tree
Hide file tree
Showing 7 changed files with 217 additions and 12 deletions.
18 changes: 16 additions & 2 deletions java/jflex/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -338,13 +338,27 @@ public static void main(String argv[]) {
try {
generate(argv);
} catch (GeneratorException e) {
Out.statistics();
if (e.isUnExpected()) {
Out.error(
"Unexpected exception encountered. This indicates a bug in JFlex."
+ Out.NL
+ "Please consider filing an issue at http://github.com/jflex-de/jflex/issues/new"
+ Out.NL);
Throwable cause = e.getCause();
if (cause != null) {
String msg = cause.getLocalizedMessage();
if (msg != null) error(msg);
cause.printStackTrace();
}
} else {
Out.statistics();
}
System.exit(1);
} catch (SilentExit e) {
System.exit(e.exitCode());
}
}

// Only CLI, not meant for instanciation.
// Only CLI, not meant for instantiation.
private Main() {}
}
40 changes: 39 additions & 1 deletion java/jflex/chars/Interval.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@

package jflex.chars;

import java.util.PrimitiveIterator;

/**
* A mutable interval of characters with basic operations.
*
* @author Gerwin Klein
* @author Régis Décamps
* @version JFlex 1.8.0-SNAPSHOT
*/
public final class Interval {
public final class Interval implements Iterable<Integer> {

/** Start of the interval. */
public int start;
Expand All @@ -32,6 +34,7 @@ public final class Interval {
public Interval(int start, int end) {
this.start = start;
this.end = end;
assert invariants();
}

/**
Expand Down Expand Up @@ -126,4 +129,39 @@ public static Interval ofCharacter(int c) {
public static Interval copyOf(Interval interval) {
return new Interval(interval.start, interval.end);
}

/**
* Checks the invariants of this object.
*
* @returns true when the invariants of this objects hold.
*/
public boolean invariants() {
return start <= end;
}

@Override
public IntervalIterator iterator() {
return new IntervalIterator();
}

/** Iterator for enumerating the elements of this Interval */
public class IntervalIterator implements PrimitiveIterator.OfInt {
/** The current iterator position */
private int pos;

/** New iterator that starts at the beginning of the */
private IntervalIterator() {
pos = start;
}

@Override
public boolean hasNext() {
return pos < end;
}

@Override
public int nextInt() {
return pos++;
}
}
}
2 changes: 1 addition & 1 deletion java/jflex/core/CharClasses.java
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,6 @@ public CharClassInterval[] getIntervals() {
* test suite) for equivalence more robust.
*/
public void normalise() {
classes.sort(null);
classes.sort((s1, s2) -> s1.compareTo(s2));
}
}
Loading

0 comments on commit 3ca3c87

Please sign in to comment.