OpenVDB  9.0.1
Parse.h
Go to the documentation of this file.
1 // Copyright Contributors to the OpenVDB Project
2 // SPDX-License-Identifier: MPL-2.0
3 
4 /// @file ast/Parse.h
5 ///
6 /// @authors Nick Avramoussis, Richard Jones
7 ///
8 /// @brief Parsing methods for creating abstract syntax trees out of AX code
9 ///
10 
11 #ifndef OPENVDB_AX_PARSE_HAS_BEEN_INCLUDED
12 #define OPENVDB_AX_PARSE_HAS_BEEN_INCLUDED
13 
14 #include "AST.h"
15 #include "../compiler/Logger.h"
16 
17 #include <openvdb/version.h>
18 
19 namespace openvdb {
21 namespace OPENVDB_VERSION_NAME {
22 
23 namespace ax {
24 namespace ast {
25 
26 /// @brief Construct an abstract syntax tree from a code snippet. If the code is
27 /// not well formed, as defined by the AX grammar, this will simply return
28 /// nullptr, with the logger collecting the errors.
29 /// @note The returned AST is const as the logger uses this to determine line
30 /// and column numbers of errors/warnings in later stages. If you need to
31 /// modify the tree, take a copy.
32 ///
33 /// @return A shared pointer to a valid const AST, or nullptr if errored.
34 ///
35 /// @param code The code to parse
36 /// @param logger The logger to collect syntax errors
37 ///
38 openvdb::ax::ast::Tree::ConstPtr parse(const char* code, ax::Logger& logger);
39 
40 /// @brief Construct an abstract syntax tree from a code snippet.
41 /// A runtime exception will be thrown with the first syntax error.
42 ///
43 /// @return A shared pointer to a valid AST.
44 ///
45 /// @param code The code to parse
46 ///
47 openvdb::ax::ast::Tree::Ptr parse(const char* code);
48 
49 } // namespace ast
50 } // namespace ax
51 
52 } // namespace OPENVDB_VERSION_NAME
53 } // namespace openvdb
54 
55 #endif // OPENVDB_AX_AST_HAS_BEEN_INCLUDED
56 
Provides the definition for every abstract and concrete derived class which represent a particular ab...
openvdb::ax::ast::Tree::ConstPtr parse(const char *code, ax::Logger &logger)
Construct an abstract syntax tree from a code snippet. If the code is not well formed, as defined by the AX grammar, this will simply return nullptr, with the logger collecting the errors.
Definition: Exceptions.h:13
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:116
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:202