FuncSketch
Loading...
Searching...
No Matches
parsed_expression.h
Go to the documentation of this file.
1/*
2 * Copyright 2026 MusicScience37 (Kenta Kabashima)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
20#pragma once
21
22#include <string>
23
24#include <boost/variant.hpp>
25#include <fmt/base.h>
26
28
29namespace func_sketch::parser {
30
38
44 std::string name;
45};
46
50
55 boost::recursive_wrapper<ParsedFunctionCallExpression>,
56 boost::recursive_wrapper<ParsedUnaryExpression>,
57 boost::recursive_wrapper<ParsedBinaryExpression>>;
58
65
67 std::vector<ParsedExpression> arguments;
68};
69
80
94
95} // namespace func_sketch::parser
96
97// Implement fmt::formatter specialization for testing.
98
103template <>
104struct fmt::formatter<func_sketch::parser::ParsedLiteral>
105 : fmt::formatter<string_view> {
114 format_context& context) const -> format_context::iterator;
115};
116
121template <>
122struct fmt::formatter<func_sketch::parser::ParsedIdentifier>
123 : fmt::formatter<string_view> {
132 format_context& context) const -> format_context::iterator;
133};
134
139template <>
140struct fmt::formatter<func_sketch::parser::ParsedExpression>
141 : fmt::formatter<string_view> {
150 format_context& context) const -> format_context::iterator;
151};
152
157template <>
158struct fmt::formatter<func_sketch::parser::ParsedFunctionCallExpression>
159 : fmt::formatter<string_view> {
168 format_context& context) const -> format_context::iterator;
169};
170
175template <>
176struct fmt::formatter<func_sketch::parser::ParsedUnaryExpression>
177 : fmt::formatter<string_view> {
186 format_context& context) const -> format_context::iterator;
187};
188
193template <>
194struct fmt::formatter<func_sketch::parser::ParsedBinaryExpression>
195 : fmt::formatter<string_view> {
204 format_context& context) const -> format_context::iterator;
205};
Definitions of common types.
std::variant< Integer, Real, Complex > Number
Type of numbers.
boost::variant< ParsedLiteral, ParsedIdentifier, boost::recursive_wrapper< ParsedFunctionCallExpression >, boost::recursive_wrapper< ParsedUnaryExpression >, boost::recursive_wrapper< ParsedBinaryExpression > > ParsedExpression
Variant of parsed expressions.
auto format(const func_sketch::parser::ParsedBinaryExpression &value, format_context &context) const -> format_context::iterator
Format a value.
auto format(const func_sketch::parser::ParsedExpression &value, format_context &context) const -> format_context::iterator
Format a value.
auto format(const func_sketch::parser::ParsedFunctionCallExpression &value, format_context &context) const -> format_context::iterator
Format a value.
auto format(const func_sketch::parser::ParsedIdentifier &value, format_context &context) const -> format_context::iterator
Format a value.
auto format(const func_sketch::parser::ParsedLiteral &value, format_context &context) const -> format_context::iterator
Format a value.
auto format(const func_sketch::parser::ParsedUnaryExpression &value, format_context &context) const -> format_context::iterator
Format a value.
Struct of parsed binary expressions.
ParsedExpression left_operand
Left operand.
ParsedExpression right_operand
Right operand.
Struct of parsed function call expressions.
std::vector< ParsedExpression > arguments
Arguments.
Struct of parsed identifiers.
Struct of parsed unary expressions.