minor Ebbn fix

This commit is contained in:
Arnaud Roques 2022-09-28 08:14:16 +02:00
parent b8913c81c4
commit cfe2b60db9
4 changed files with 13 additions and 16 deletions

View File

@ -63,8 +63,8 @@ public class ResultPoint {
}
/**
* <p>Orders an array of three ResultPoints in an order [A,B,C] such that AB < AC and
* BC < AC and the angle between BC and BA is less than 180 degrees.
* <p>Orders an array of three ResultPoints in an order [A,B,C] such that AB is less than AC
* and BC is less than AC and the angle between BC and BA is less than 180 degrees.
*/
public static void orderBestPatterns(ResultPoint[] patterns) {

View File

@ -59,6 +59,7 @@ public class EbnfSingleExpression {
} else if (isLetterOrDigit(ch)) {
final String litteral = readLitteral(it);
tokens.add(new Token(Symbol.LITTERAL, litteral));
continue;
} else if (ch == ',') {
tokens.add(new Token(Symbol.CONCATENATION, null));
} else if (ch == '|') {
@ -125,9 +126,9 @@ public class EbnfSingleExpression {
engine.alternation();
else if (element.getSymbol() == Symbol.CONCATENATION)
engine.concatenation();
else if (element.getSymbol() == Symbol.OPTIONAL_CLOSE)
else if (element.getSymbol() == Symbol.OPTIONAL)
engine.optional();
else if (element.getSymbol() == Symbol.REPETITION_CLOSE)
else if (element.getSymbol() == Symbol.REPETITION)
engine.repetition();
else
throw new UnsupportedOperationException(element.toString());

View File

@ -65,21 +65,15 @@ public class ShuntingYard {
if (operatorStack.peekFirst().getSymbol() == Symbol.GROUPING_OPEN)
operatorStack.removeFirst();
} else if (token.getSymbol() == Symbol.OPTIONAL_OPEN) {
operatorStack.addFirst(token);
operatorStack.addFirst(new Token(Symbol.OPTIONAL, null));
} else if (token.getSymbol() == Symbol.OPTIONAL_CLOSE) {
while (operatorStack.peekFirst().getSymbol() != Symbol.OPTIONAL_OPEN)
ouputQueue.add(operatorStack.removeFirst());
if (operatorStack.peekFirst().getSymbol() == Symbol.OPTIONAL_OPEN)
operatorStack.removeFirst();
operatorStack.addFirst(token);
final Token first = operatorStack.removeFirst();
ouputQueue.add(first);
} else if (token.getSymbol() == Symbol.REPETITION_OPEN) {
operatorStack.addFirst(token);
operatorStack.addFirst(new Token(Symbol.REPETITION, null));
} else if (token.getSymbol() == Symbol.REPETITION_CLOSE) {
while (operatorStack.peekFirst().getSymbol() != Symbol.REPETITION_OPEN)
ouputQueue.add(operatorStack.removeFirst());
if (operatorStack.peekFirst().getSymbol() == Symbol.REPETITION_OPEN)
operatorStack.removeFirst();
operatorStack.addFirst(token);
final Token first = operatorStack.removeFirst();
ouputQueue.add(first);
} else {
throw new UnsupportedOperationException(token.toString());
}

View File

@ -46,8 +46,10 @@ public enum Symbol {
ALTERNATION, // |
OPTIONAL_OPEN, // [
OPTIONAL_CLOSE, // ]
OPTIONAL,
REPETITION_OPEN, // {
REPETITION_CLOSE, // }
REPETITION, //
GROUPING_OPEN, // (
GROUPING_CLOSE, // )
TERMINAL_STRING1, // " "