ALib C++ Library
Library Version: 2402 R1
Documentation generated by doxygen
Loading...
Searching...
No Matches
parser.hpp
Go to the documentation of this file.
1/** ************************************************************************************************
2 * \file
3 * This header file is part of module \alib_expressions of the \aliblong.
4 *
5 * \emoji :copyright: 2013-2024 A-Worx GmbH, Germany.
6 * Published under \ref mainpage_license "Boost Software License".
7 **************************************************************************************************/
8#ifndef HPP_ALIB_EXPRESSIONS_DETAIL_PARSER
9#define HPP_ALIB_EXPRESSIONS_DETAIL_PARSER
10
11#if !defined (HPP_ALIB_STRINGS_NUMBERFORMAT)
13#endif
14
15ALIB_ASSERT_MODULE(EXPRESSIONS)
16
17
18namespace alib {
19
20namespace monomem { class MonoAllocator; }
21
22namespace expressions {
23
24class Compiler;
25
26namespace detail {
27
28struct AST;
29
30
31/** ************************************************************************************************
32 * This detail class constitutes an abstract base class for expression parsers.
33 **************************************************************************************************/
34struct Parser
35{
36 /**
37 * Virtual destructor.
38 */
39 virtual ~Parser()
40 {}
41
42 /**
43 * Parses the given expression string.
44 * \note
45 * The return value is hidden by using <c>void*</c>. This is to allow avoid flooding
46 * of \c boost header includes files to the code entities using module \alib_expressions_nl.
47 *
48 * @param expressionString The string to parse.
49 * @param numberFormat Used to parse literal numbers.
50 * @param allocator Used for temporary objects, including AST nodes, converted string
51 * data, etc.
52 * @return The abstract syntax tree representing the expression.
53 */
54 virtual detail::AST* Parse( const String& expressionString,
55 NumberFormat* numberFormat,
56 monomem::MonoAllocator* allocator ) = 0;
57
58
59 /**
60 * Static method to create a parser object.
61 *
62 * @param compiler The compiler that needs a parser.
63 * @return The parser.
64 */
65 ALIB_API static
66 Parser* Create( Compiler& compiler );
67};
68
69}}} // namespace [alib::expressions::detail]
70
71
72#endif // HPP_ALIB_EXPRESSIONS_DETAIL_PARSER
#define ALIB_ASSERT_MODULE(modulename)
Definition alib.hpp:190
#define ALIB_API
Definition alib.hpp:538
Definition alib.cpp:57
monomem::MonoAllocator MonoAllocator
Type alias in namespace alib.
expressions::Compiler Compiler
Type alias in namespace alib.
Definition compiler.hpp:596
static ALIB_API Parser * Create(Compiler &compiler)
Definition parser.cpp:25
virtual detail::AST * Parse(const String &expressionString, NumberFormat *numberFormat, monomem::MonoAllocator *allocator)=0