AsmGrader 0.0.0
Loading...
Searching...
No Matches
syntax_highlighter.hpp File Reference

Syntax highlighting of expressions as generated in expression_inspection.hpp using {fmt}'s color API. More...

#include <asmgrader/api/expression_inspection.hpp>
#include <asmgrader/logging.hpp>
#include <fmt/base.h>
#include <fmt/color.h>
#include <fmt/format.h>
#include <libassert/assert.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/algorithm/transform.hpp>
#include <range/v3/iterator/concepts.hpp>
#include <range/v3/range/access.hpp>
#include <range/v3/range/concepts.hpp>
#include <range/v3/range/conversion.hpp>
#include <range/v3/range/primitives.hpp>
#include <range/v3/view/enumerate.hpp>
#include <range/v3/view/join.hpp>
#include <range/v3/view/split.hpp>
#include <range/v3/view/split_when.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.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  asmgrader::highlight::Options
 
struct  asmgrader::highlight::Options::Opt
 

Namespaces

namespace  asmgrader
 
namespace  asmgrader::highlight
 

Typedefs

using asmgrader::highlight::Option = std::pair<inspection::Token::Kind, fmt::text_style>
 

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.
 

Detailed Description

Syntax highlighting of expressions as generated in expression_inspection.hpp using {fmt}'s color API.