use of common.SyntaxException in project solution-finder by knewjade.
the class PatternInterpreter method wildcard.
private WildcardElement wildcard() throws SyntaxException {
boolean blankNext = token.isBlankNext();
switch(token.check()) {
case "P":
if (blankNext)
throw new SyntaxException("Contains invalid character between * and p", token.getLastIndex());
token.skip();
int size = token.nextInt();
if (size <= 0)
throw new SyntaxException("no pop", token.getLastIndex());
else if (8 <= size)
throw new SyntaxException("over pop", token.getLastIndex());
return new WildcardElement(size);
case "!":
if (blankNext)
throw new SyntaxException("Contains invalid character between * and !", token.getLastIndex());
token.skip();
return new WildcardElement(7);
default:
return new WildcardElement(1);
}
}
use of common.SyntaxException in project solution-finder by knewjade.
the class PatternInterpreter method getCombinationTokenList.
private LinkedList<String> getCombinationTokenList() throws SyntaxException {
int depth = 1;
LinkedList<String> inner = new LinkedList<>();
while (true) {
String pop = token.pop();
if (Token.isEmptyString(pop))
throw new SyntaxException("Not found ']'", token.getLastIndex());
switch(pop) {
case "[":
depth += 1;
break;
case "]":
depth -= 1;
if (depth == 0)
return inner;
break;
}
inner.add(pop);
}
}
use of common.SyntaxException in project solution-finder by knewjade.
the class PathEntryPoint method createPathCore.
private PathCore createPathCore(Field field, int maxClearLine, int maxDepth, List<String> patterns, MinoFactory minoFactory, ColorConverter colorConverter, SizedBit sizedBit, SolutionFilter solutionFilter, boolean isUsingHold, BasicSolutions basicSolutions, int threadCount) throws FinderInitializeException, FinderExecuteException {
assert 1 <= threadCount;
List<InOutPairField> inOutPairFields = InOutPairField.createInOutPairFields(sizedBit, field);
TaskResultHelper taskResultHelper = createTaskResultHelper(maxClearLine);
PerfectPackSearcher searcher = new PerfectPackSearcher(inOutPairFields, basicSolutions, sizedBit, solutionFilter, taskResultHelper, threadCount != 1);
FumenParser fumenParser = createFumenParser(settings.isTetfuSplit(), minoFactory, colorConverter);
ThreadLocal<BuildUpStream> threadLocalBuildUpStream = createBuildUpStreamThreadLocal(settings.getDropType(), maxClearLine);
try {
return new PathCore(patterns, searcher, maxDepth, isUsingHold, fumenParser, threadLocalBuildUpStream);
} catch (SyntaxException e) {
output("Pattern syntax error");
output(e.getMessage());
throw new FinderInitializeException("Pattern syntax error", e);
}
}
use of common.SyntaxException in project solution-finder by knewjade.
the class PatternInterpreter method parseNormalBlockSet.
private HashSet<Piece> parseNormalBlockSet(Token token) throws SyntaxException {
HashSet<Piece> pieces = new HashSet<>();
while (token.isContinue()) {
Piece piece = token.nextBlock();
if (pieces.contains(piece))
throw new SyntaxException(String.format("Duplicate '%s' pieces in []", piece.getName()), token.getLastIndex());
pieces.add(piece);
}
return pieces;
}
use of common.SyntaxException in project solution-finder by knewjade.
the class PatternInterpreter method combination.
private Element combination() throws SyntaxException {
int lastIndex = token.getLastIndex();
LinkedList<String> combinationTokenList = getCombinationTokenList();
Token subToken = Token.createSubToken(combinationTokenList, lastIndex);
HashSet<Piece> pieceSet = parseBlockSet(subToken);
if (pieceSet.isEmpty())
throw new SyntaxException("Empty in []", token.getLastIndex());
boolean blankNext = token.isBlankNext();
switch(token.check()) {
case "P":
if (blankNext)
throw new SyntaxException("Contains invalid character between [] and p", token.getLastIndex());
this.token.skip();
int size = this.token.nextInt();
if (pieceSet.size() <= 0)
throw new SyntaxException("no pop", token.getLastIndex());
else if (pieceSet.size() < size)
throw new SyntaxException("over pop", token.getLastIndex());
return new BracketElement(pieceSet, size);
case "!":
if (blankNext)
throw new SyntaxException("Contains invalid character between [] and !", token.getLastIndex());
this.token.skip();
return new BracketElement(pieceSet, pieceSet.size());
default:
return new BracketElement(pieceSet, 1);
}
}
Aggregations