diff --git a/src/ext/plantuml/com/google/zxing/ResultPoint.java b/src/ext/plantuml/com/google/zxing/ResultPoint.java index 3ea9eb671..30a7eac9c 100644 --- a/src/ext/plantuml/com/google/zxing/ResultPoint.java +++ b/src/ext/plantuml/com/google/zxing/ResultPoint.java @@ -63,8 +63,8 @@ public class ResultPoint { } /** - *

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. + *

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) { diff --git a/src/net/sourceforge/plantuml/ebnf/EbnfSingleExpression.java b/src/net/sourceforge/plantuml/ebnf/EbnfSingleExpression.java index 7bf12422e..bb219ce03 100644 --- a/src/net/sourceforge/plantuml/ebnf/EbnfSingleExpression.java +++ b/src/net/sourceforge/plantuml/ebnf/EbnfSingleExpression.java @@ -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()); diff --git a/src/net/sourceforge/plantuml/ebnf/ShuntingYard.java b/src/net/sourceforge/plantuml/ebnf/ShuntingYard.java index 31d5b5d1b..a26e61d2e 100644 --- a/src/net/sourceforge/plantuml/ebnf/ShuntingYard.java +++ b/src/net/sourceforge/plantuml/ebnf/ShuntingYard.java @@ -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()); } diff --git a/src/net/sourceforge/plantuml/ebnf/Symbol.java b/src/net/sourceforge/plantuml/ebnf/Symbol.java index 90af08d92..6723d953d 100644 --- a/src/net/sourceforge/plantuml/ebnf/Symbol.java +++ b/src/net/sourceforge/plantuml/ebnf/Symbol.java @@ -46,8 +46,10 @@ public enum Symbol { ALTERNATION, // | OPTIONAL_OPEN, // [ OPTIONAL_CLOSE, // ] + OPTIONAL, REPETITION_OPEN, // { REPETITION_CLOSE, // } + REPETITION, // GROUPING_OPEN, // ( GROUPING_CLOSE, // ) TERMINAL_STRING1, // " "