AsmGrader 0.0.0
Loading...
Searching...
No Matches
syntax_highlighter.cpp File Reference
#include "api/syntax_highlighter.hpp"
#include "api/expression_inspection.hpp"
#include "logging.hpp"
#include <fmt/base.h>
#include <fmt/color.h>
#include <fmt/format.h>
#include <libassert/assert.hpp>
#include <range/v3/action/transform.hpp>
#include <range/v3/algorithm/contains.hpp>
#include <range/v3/algorithm/find.hpp>
#include <range/v3/algorithm/find_if.hpp>
#include <range/v3/algorithm/fold_left.hpp>
#include <range/v3/range/access.hpp>
#include <range/v3/range/concepts.hpp>
#include <range/v3/range/conversion.hpp>
#include <range/v3/view/enumerate.hpp>
#include <range/v3/view/join.hpp>
#include <range/v3/view/transform.hpp>
#include <array>
#include <charconv>
#include <cstddef>
#include <functional>
#include <span>
#include <string>
#include <string_view>
#include <system_error>
#include <utility>
#include <vector>
Include dependency graph for syntax_highlighter.cpp:

Namespaces

namespace  asmgrader
 
namespace  asmgrader::highlight
 

Functions

std::string asmgrader::highlight::render_blocks (std::string_view str, bool skip_styling)
 Parses and renders literal blocks, returning a form meant for displaying to a console user, as by means of fmt::styled. The syntax for a literal string is a sequence of characters started by the sequence %#` and ended by a single backtick `. Backticks within the sequence may be escaped using \`.
 
std::string asmgrader::highlight::highlight (std::string_view str, const Options &opts=Options::get_default_options())
 Applies syntax highlighting to str by means of first passing it through inspection::Tokenizer, then applying highlighting as specified by opts to the obtained tokens.
 
std::string asmgrader::highlight::highlight (const inspection::Token &token, const Options &opts=Options::get_default_options())
 Returns a stringified and highlighted version of the supplied token. Highlighting and spacing is done based on opts.
 
std::string asmgrader::highlight::highlight (std::span< const inspection::Token > tokens, const Options &opts=Options::get_default_options())
 Returns a stringified and highlighted version of the supplied range of tokens. Highlighting and spacing is done based on opts.
 

Variable Documentation

◆ end

std::size_t end {}

End of the block, non-inclusive i.e. of the final ` delimiter Will be the same as end_delim for now.

◆ end_delim

std::size_t end_delim {}

Position of the end delimiter char.

◆ start

std::size_t start {}

Start of the block, inclusive i.e. position after the starting delimiter and style spec.

◆ start_delim

std::size_t start_delim {}

Position of the first char of the start delimiter.

◆ style_specs

std::vector<std::string_view> style_specs

Possibly empty sequence of style specifiers found between leading < > tokens E.g.:

%#`<bold,fg:#FFFFFF,bg:blue>this is text`

style_specs = {"bold", "fg:#FFFFFF", "bg:blue"}