Пример #1
0
void threaded_sax_token_parser<_Handler>::parse()
{
    std::thread t(&threaded_sax_token_parser::thread_parse, this);
    detail::thread::scoped_guard guard(std::move(t));

    sax::parse_tokens_t tokens;

    while (m_parser_thread.next_tokens(tokens))
        process_tokens(tokens);

    process_tokens(tokens);
}
Пример #2
0
void Checker::process_file()
{
    srchilite::RegexRuleFactory rule_factory;
    srchilite::LangDefManager lang_def_manager(&rule_factory);
    srchilite::SourceHighlighter highlighter(
        lang_def_manager.getHighlightState(LANG_PATH, file_language.second));
    srchilite::FormatterManager manager(
        PseudoFormatterPtr(new PseudoFormatter(token_types, tokens, env.current_line_index)));

    manager.addFormatter("cbracket_open", new_formatter("cbracket_open"));
    manager.addFormatter("cbracket_close", new_formatter("cbracket_close"));
    manager.addFormatter("pasbracket_open", new_formatter("pasbracket_open"));
    manager.addFormatter("pasbracket_close", new_formatter("pasbracket_close"));

    manager.addFormatter("keyword", new_formatter("keyword"));
    manager.addFormatter("number", new_formatter("number"));
    manager.addFormatter("label", new_formatter("label"));
    manager.addFormatter("preproc", new_formatter("preproc"));
    manager.addFormatter("comment", new_formatter("comment"));
    manager.addFormatter("string", new_formatter("string"));
    manager.addFormatter("specialchar", new_formatter("string"));
    manager.addFormatter("symbol", new_formatter("symbol"));

    manager.addFormatter("type", new_formatter("type"));
    manager.addFormatter("usertype", new_formatter("classname"));
    manager.addFormatter("classname", new_formatter("classname"));
    manager.addFormatter("function", new_formatter("function"));
    manager.addFormatter("identifier", new_formatter("identifier"));

    manager.addFormatter("case", new_formatter("case"));
    manager.addFormatter("of", new_formatter("of"));
    manager.addFormatter("typeblock", new_formatter("typeblock"));
    manager.addFormatter("varblock", new_formatter("varblock"));
    manager.addFormatter("keyword_declaring_varblock", new_formatter("keyword_declaring_varblock"));
    manager.addFormatter("keyword_declaring_func", new_formatter("keyword_declaring_func"));

    manager.addFormatter(
        "keyword_with_following_operation", new_formatter("keyword_with_following_operation"));
    manager.addFormatter(
        "keyword_with_following_operation_after_braces",
        new_formatter("keyword_with_following_operation_after_braces"));
    manager.addFormatter("switch_labels", new_formatter("switch_labels"));
    manager.addFormatter("semicolon", new_formatter("semicolon"));
    manager.addFormatter("brace", new_formatter("brace"));
    manager.addFormatter("bracket", new_formatter("bracket"));

    highlighter.setFormatterManager(&manager);

    srchilite::FormatterParams params;
    highlighter.setFormatterParams(&params);

    for(env.current_line_index = 0; file_to_process.good(); ++env.current_line_index)
    {
        getline(file_to_process, env.current_line);
        check_line_length();
        check_if_empty();
        lines.push_back(LineInfo(env.current_line, env.current_line.size(), 0, 0, 0));
        if(env.current_line.size() != 0)
        {
            params.start = 0;
            highlighter.highlightParagraph(env.current_line);
        };
    }
    check_newline_at_eof();
    calculate_expected_depth();
    if(settings.indentation_policy != IP_IGNORE)
        check_indentation();
    process_tokens();
}