OpenVDB: openvdb_ax/ast/Parse.h Source File

OpenVDB 10.0.1

Loading...
Searching...
No Matches
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.
27/// @details This method parses the provided null terminated code snippet and
28/// attempts to construct a complete abstract syntax tree (AST) which can be
29/// passed to the AX Compiler. If the code is not well formed (as defined by
30/// the AX grammar) a nullptr is returned and instances of any errors
31/// encoutered are stored to the provided logger.
32/// @note The returned AST is const as the logger uses this to determine line
33/// and column numbers of errors/warnings in later stages. If you need to
34/// modify the tree, take a copy.
35///
36/// @return A shared pointer to a valid const AST. Can be a nullptr on error.
37/// @todo In the future it may be useful for ::parse to return as much of
38/// the valid AST that exists.
39///
40/// @param code The code to parse
41/// @param logger The logger to collect syntax errors
42///
43 OPENVDB_AX_API openvdb::ax::ast::Tree::ConstPtr
44parse(const char* code, ax::Logger& logger);
45
46/// @brief Construct an abstract syntax tree from a code snippet.
47/// @details A runtime exception will be thrown with the first syntax error.
48///
49/// @return A shared pointer to a valid AST.
50///
51/// @param code The code to parse
52///
53 OPENVDB_AX_API openvdb::ax::ast::Tree::Ptr
54 parse(const char* code);
55
56} // namespace ast
57} // namespace ax
58
59} // namespace OPENVDB_VERSION_NAME
60} // namespace openvdb
61
62#endif // OPENVDB_AX_AST_HAS_BEEN_INCLUDED
63
AST.h
Provides the definition for every abstract and concrete derived class which represent a particular ab...
OPENVDB_AX_API
#define OPENVDB_AX_API
Definition: Platform.h:272
openvdb::v10_0::ax::Logger
Logger for collecting errors and warnings that occur during AX compilation.
Definition: Logger.h:58
openvdb::v10_0::ax::ast::parse
OPENVDB_AX_API openvdb::ax::ast::Tree::ConstPtr parse(const char *code, ax::Logger &logger)
Construct an abstract syntax tree from a code snippet.
openvdb
Definition: Exceptions.h:13
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:121
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:212