1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-10-31 19:22:31 +00:00

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

View File

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

View File

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

View File

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