OpenVDB: openvdb_ax/ast/Parse.h Source File

OpenVDB 9.0.0

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
19namespace openvdb {
20 OPENVDB_USE_VERSION_NAMESPACE
21namespace OPENVDB_VERSION_NAME {
22
23namespace ax {
24namespace 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///
38openvdb::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///
47openvdb::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
AST.h
Provides the definition for every abstract and concrete derived class which represent a particular ab...
openvdb::v9_0::ax::Logger
Logger for collecting errors and warnings that occur during AX compilation.
Definition: Logger.h:55
openvdb::v9_0::ax::ast::parse
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,...
openvdb
Definition: Exceptions.h:13
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:116
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:202