Exemplo n.º 1
0
    State validate(QString &input, int & /* pos */) const override
    {
        if (input.isEmpty())
            return State::Intermediate;

        const bool valid = input.length() == 1 && isValidPrefix(input[0].toLatin1());
        return valid ? State::Acceptable : State::Invalid;
    }
Exemplo n.º 2
0
//runs a dfs to check word combinations. After a combination is 3 characters or longer, it sends it to isValidWord and prints it if that returns 1.
void checkSpot(int x, int y, int **visited, char** board, char *tempWord,trie *dictionary, int counter){

    int  i;
    tempWord[counter - 1] = board[x][y];
    tempWord[counter] = '\0';
    for (i = 0; i < DIRECTIONS; ++i) {
        if(isValid(x+dx[i], y+dy[i]) && !visited[x+dx[i]][y+dy[i]]){
            if(!isValidPrefix(dictionary,tempWord,counter)){
                return;
            }
            if(counter >= 3){
                if(isValidWord(dictionary,tempWord)){
                    printf("%s\n", tempWord);
                }
            }
                visited[x][y] = 1;
                checkSpot(x + dx[i], y + dy[i], visited, board, tempWord, dictionary, counter + 1);
                visited[x][y] = 0;

        }
    }
}
Exemplo n.º 3
0
void AbstractParser::parseSetCommand(StringView view)
{
    if (view.isEmpty()) {
        sendToUser(QString("Syntax: %1set prefix [punct-char]\r\n").arg(prefixChar));
        return;
    }

    auto first = view.takeFirstWord();
    if (Abbrev{"prefix", 3}.matches(first)) {
        if (view.isEmpty()) {
            showCommandPrefix();
            return;
        }

        auto next = view.takeFirstWord();
        if (next.size() == 3) {
            auto quote = next.takeFirstLetter();
            const bool validQuote = quote == '\'' || quote == '"';
            const auto prefix = next.takeFirstLetter().toLatin1();

            if (validQuote && isValidPrefix(prefix) && quote == next.takeFirstLetter()
                && quote != prefix && setCommandPrefix(prefix)) {
                return;
            }
        } else if (next.size() == 1) {
            const auto prefix = next.takeFirstLetter().toLatin1();
            if (setCommandPrefix(prefix)) {
                return;
            }
        }

        sendToUser("Invalid prefix.\r\n");
        return;
    }

    sendToUser("That variable is not supported.");
}