FuncSketch
Loading...
Searching...
No Matches
expression_parser.cpp
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 */
21
22#include <memory>
23
24#include <boost/variant.hpp>
25
30
31namespace func_sketch::parser {
32
45
47
49 ExpressionParser&& /*other*/) noexcept = default;
50
52 ExpressionParser&& /*other*/) noexcept = default;
53
55
56expressions::ExpressionPtr ExpressionParser::operator()(
57 const std::string& expression_str) const {
58 const auto parsed_expression = pimpl_->grammar.parse(expression_str);
59 return convert_expression(
60 parsed_expression, pimpl_->math_function_list, pimpl_->constant_list);
61}
62
63} // namespace func_sketch::parser
Class of lists of constants.
Class of lists of mathematical functions.
Class of grammar for parsing expressions.
Class of parser for expressions.
std::unique_ptr< Impl > pimpl_
Internal data.
ConstantList generate_constant_list()
Generate a list of built-in constants.
Declaration of convert_expression function.
expressions::ExpressionPtr convert_expression(const ParsedExpression &parsed_expression, const math::MathFunctionList &math_function_list, const math::ConstantList &constant_list)
Convert parsed expression.
Definition of ExpressionGrammar class.
Definition of ExpressionParser class.
Declaration of generate_math_function_list function.
MathFunctionList generate_math_function_list()
Generate a list of mathematical functions.
Definition of MathFunctionList class.
Internal data of ExpressionParser class.
math::ConstantList constant_list
List of constants.
ExpressionGrammar grammar
Grammar for parsing expressions.
math::MathFunctionList math_function_list
List of mathematical functions.