AsmGrader 0.0.0
Loading...
Searching...
No Matches
expression_inspection.hpp File Reference
#include <asmgrader/common/cconstexpr.hpp>
#include <asmgrader/common/formatters/macros.hpp>
#include <asmgrader/logging.hpp>
#include <fmt/format.h>
#include <gsl/narrow>
#include <libassert/assert.hpp>
#include <range/v3/algorithm/any_of.hpp>
#include <range/v3/algorithm/contains.hpp>
#include <range/v3/algorithm/copy.hpp>
#include <range/v3/algorithm/count.hpp>
#include <range/v3/algorithm/count_if.hpp>
#include <range/v3/algorithm/equal.hpp>
#include <range/v3/algorithm/find.hpp>
#include <range/v3/algorithm/find_if.hpp>
#include <range/v3/algorithm/find_if_not.hpp>
#include <range/v3/algorithm/sort.hpp>
#include <range/v3/range/access.hpp>
#include <range/v3/range/concepts.hpp>
#include <range/v3/view/any_view.hpp>
#include <range/v3/view/enumerate.hpp>
#include <range/v3/view/take.hpp>
#include <range/v3/view/take_while.hpp>
#include <range/v3/view/transform.hpp>
#include <algorithm>
#include <array>
#include <concepts>
#include <cstddef>
#include <exception>
#include <functional>
#include <optional>
#include <span>
#include <string>
#include <string_view>
#include <type_traits>
#include <utility>
Include dependency graph for expression_inspection.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  asmgrader::inspection::Token
 Token of a very basic C++ expression. The primary use case is for rudemtary console syntax coloring. More...
 
class  asmgrader::inspection::ParsingError
 Bad or invalid parse exception type. May indicate an implementation bug, or just an invalid expression. More...
 
struct  asmgrader::inspection::tokenize::CaseInsensitiveTag
 
class  asmgrader::inspection::tokenize::Stream
 
struct  asmgrader::inspection::tokenize::Stream::StreamContext
 Primarily used to support Token::Kind::Grouping. More...
 
class  asmgrader::inspection::Tokenizer< MaxNumTokens >
 

Namespaces

namespace  asmgrader
 
namespace  asmgrader::inspection
 
namespace  asmgrader::inspection::tokenize
 Recursive descent parser implementation details.
 

Functions

constexpr std::string_view asmgrader::inspection::format_as (const Token::Kind token_kind)
 
constexpr std::pair< Token::Kind, std::string_view > asmgrader::inspection::format_as (const Token &tok)
 
const std::exception & asmgrader::inspection::format_as (const ParsingError &err)
 
constexpr std::string_view asmgrader::inspection::tokenize::substr_to (std::string_view str, auto token)
 A substr of str up to the first occurrence of token, or the entirety of str if token is not found.
 
constexpr std::string_view asmgrader::inspection::tokenize::substr_to (std::string_view str, std::invocable< char > auto pred)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. A substr of str up to the first character that satisfies pred, or the entirety of str if pred is never satisfied In essence, performs 'take while not' (a.k.a. 'take until')
 
constexpr std::string_view asmgrader::inspection::tokenize::substr_past (std::string_view str, auto what)
 A substr of str past all characters satisfying pred In essence, performs 'drop while'.
 
template<std::size_t N>
constexpr auto asmgrader::inspection::tokenize::make_rev_size_sorted (const std::string_view(&arr)[N])
 
constexpr bool asmgrader::inspection::tokenize::is_strlike_prefix (std::string_view str)
 Whether the entirety of str is a strlike-prefix See Token::Kind::StringLiteral for details.
 
constexpr bool asmgrader::inspection::tokenize::is_int_suffix (std::string_view str)
 Whether the entirety of str is an integer-suffix See Token::Kind::IntLiteral for details.
 
constexpr auto asmgrader::inspection::tokenize::is_ident_like ()
 Returns a functor to check for an identifier for a stream of characters Does not verify whether the ident is a reserved token or not. See Token::Kind::Identifier for details.
 
constexpr auto asmgrader::inspection::tokenize::digit_or_sep (char c)
 Exactly as named. Sep = '.
 
constexpr auto asmgrader::inspection::tokenize::xdigit_or_sep (char c)
 Exactly as named. Sep = '.
 
template<Token::Kind Kind>
constexpr bool asmgrader::inspection::tokenize::matches (const Stream &stream)
 Check whether the start of stream matches a token kind Assumes that there is no leading whitespace in stream
 
template<>
constexpr bool asmgrader::inspection::tokenize::matches< StringLiteral > (const Stream &stream)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Whether the start of stream is a string literal token See Token::Kind::StringLiteral for details.
 
template<>
constexpr bool asmgrader::inspection::tokenize::matches< RawStringLiteral > (const Stream &stream)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Whether the start of stream is a raw string literal token See Token::Kind::RawStringLiteral for details.
 
template<>
constexpr bool asmgrader::inspection::tokenize::matches< CharLiteral > (const Stream &stream)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Whether the start of stream is a char literal token See Token::Kind::CharLiteral for details.
 
template<>
constexpr bool asmgrader::inspection::tokenize::matches< BoolLiteral > (const Stream &stream)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. See Token::Kind::BoolLiteral for details.
 
template<>
constexpr bool asmgrader::inspection::tokenize::matches< IntBinLiteral > (const Stream &stream)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Whether the start of stream is a binary integer literal token See Token::Kind::IntBinLiteral for details.
 
template<>
constexpr bool asmgrader::inspection::tokenize::matches< IntHexLiteral > (const Stream &stream)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Whether the start of stream is a hexadecimal integer literal token See Token::Kind::IntHexLiteral for details.
 
template<>
constexpr bool asmgrader::inspection::tokenize::matches< IntOctLiteral > (const Stream &stream)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Whether the start of stream is an octal integer literal token See Token::Kind::IntOctLiteral for details.
 
template<>
constexpr bool asmgrader::inspection::tokenize::matches< IntDecLiteral > (const Stream &stream)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Whether the start of stream is a decimal integer literal token Written in terms of other int literals. See Token::Kind::IntDecLiteral for details.
 
template<>
constexpr bool asmgrader::inspection::tokenize::matches< FloatHexLiteral > (const Stream &stream)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Whether the start of stream is a hexadecimal floating point literal token See Token::Kind::FloatLiteral for details.
 
template<>
constexpr bool asmgrader::inspection::tokenize::matches< FloatLiteral > (const Stream &stream)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Whether the start of stream is a floating point literal token See Token::Kind::FloatLiteral for details.
 
template<>
constexpr bool asmgrader::inspection::tokenize::matches< Identifier > (const Stream &stream)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Whether the start of stream is an identifier token See Token::Kind::Identifier for details.
 
template<>
constexpr bool asmgrader::inspection::tokenize::matches< Grouping > (const Stream &stream)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Whether the start of stream is an identifier token See Token::Kind::Identifier for details.
 
template<>
constexpr bool asmgrader::inspection::tokenize::matches< BinaryOperator > (const Stream &stream)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Whether the start of stream is a binary operator token See Token::Kind::BinaryOperator for details.
 
template<>
constexpr bool asmgrader::inspection::tokenize::matches< Operator > (const Stream &stream)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Whether the start of stream is an operator token See Token::Kind::Operator for details.
 
template<Token::Kind Kind>
constexpr std::string_view asmgrader::inspection::tokenize::test_parse (std::string_view str)
 
template<Token::Kind Kind>
constexpr std::string_view asmgrader::inspection::tokenize::parse (Stream &stream)
 Parse the token of Kind from the start of the stream. Assumes that the stream actually starts with a token of Kind. (Check with match)
 
template<>
constexpr std::string_view asmgrader::inspection::tokenize::parse< StringLiteral > (Stream &stream)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. See Token::Kind::StringLiteral for details.
 
template<std::size_t MaxNumTokens>
constexpr auto asmgrader::inspection::parse_tokens (std::string_view str)
 

Variables

constexpr struct asmgrader::inspection::tokenize::CaseInsensitiveTag asmgrader::inspection::tokenize::case_insensitive
 
constexpr auto asmgrader::inspection::tokenize::binary_operator_tokens
 
constexpr auto asmgrader::inspection::tokenize::operator_tokens
 
constexpr auto asmgrader::inspection::tokenize::grouping_tokens