Skip to content
Extraits de code Groupes Projets
Sélectionner une révision Git
  • 64277e9bc5cd6d74b6edafa93e68b061f24ca9b1
  • develop par défaut protégée
  • implement-discord-markdown-update
  • matrix-attachments-order-fix
  • fix-oversized-file-transfer
  • matrix-attachment-order-fix
  • matrix-answer-modified-fix
  • cherry-pick-moise
8 résultats

matrixeventprocessor.ts

Blame
  • Bifurcation depuis ARISE / matrix-appservice-discord
    Le projet source a une visibilité limitée.
    Lexer.cc 8,22 Kio
    #include "StrV.hh"
    #include "Lexer.hh"
    #include "Tokens.hh"
    #include <fstream>
    
    namespace Vivy::Script
    {
    static void
    readFileIntoStdString(const char *filePath, std::string *retString)
    {
        std::ifstream file(filePath);
        if (file.is_open()) {
            file.seekg(0, std::ios::end);
            std::streamoff size = file.tellg();
            if ((size == std::streamoff(-1)) || (size < 0))
                throw std::runtime_error("Failed to get the size of the file " + std::string(filePath));
            retString->reserve(static_cast<std::size_t>(size));
            file.seekg(0, std::ios::beg);
    
            retString->assign((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
            file.close();
        }
    
        else
            throw std::runtime_error("Failed to open the file " + std::string(filePath));
    }
    
    static void
    getRideOfComments(std::string *retString)
    {
        std::size_t begin;
        do /* Single line */ {
            begin                 = retString->find("--");
            const std::size_t end = retString->find("\n", begin);
    
            if (std::string::npos != begin && std::string::npos != end && begin <= end) {
                for (std::size_t i = begin; i < end; ++i)
                    (*retString)[i] = ' ';
            }
    
            else if (std::string::npos != begin && std::string::npos == end)
                retString->resize(begin);
        } while (begin != std::string::npos);
    }
    
    static void
    promoteQNameToSimpleTokens(TokenList *tokens) noexcept
    {
        for (size_t i = 0; i < tokens->size(); i += 1) {
            Token tok = tokens->at(i);
            if (!tok.isQName())
                continue;
            StrV qnameToPromote = tok.asQName();
    
            for (const auto &simpleToken : Vivy::Script::SIMPLE_TOKENS) {
                if (StrV::equal(qnameToPromote, simpleToken))
                    tokens->at(i) = Token::fromSimple(tok.location(), qnameToPromote);
            }
        }
    }
    
    void
    tokenizeFile(const char *file, TokenList *tokens, std::string *storage)
    {
        union {
            double floating;
            int integer;
            StrV qualifiedName = STRV_NULL;
        };
        bool ok;