Loading...
Searching...
No Matches
Parse.h
Go to the documentation of this file.
// Copyright Contributors to the OpenVDB Project
// SPDX-License-Identifier: MPL-2.0
/// @file ast/Parse.h
///
/// @authors Nick Avramoussis, Richard Jones
///
/// @brief Parsing methods for creating abstract syntax trees out of AX code
///
#ifndef OPENVDB_AX_PARSE_HAS_BEEN_INCLUDED
#define OPENVDB_AX_PARSE_HAS_BEEN_INCLUDED
#include "AST.h"
#include "../compiler/Logger.h"
#include <openvdb/version.h>
namespace openvdb {
OPENVDB_USE_VERSION_NAMESPACE
namespace OPENVDB_VERSION_NAME {
namespace ax {
namespace ast {
/// @brief Construct an abstract syntax tree from a code snippet.
/// @details This method parses the provided null terminated code snippet and
/// attempts to construct a complete abstract syntax tree (AST) which can be
/// passed to the AX Compiler. If the code is not well formed (as defined by
/// the AX grammar) a nullptr is returned and instances of any errors
/// encoutered are stored to the provided logger.
/// @note The returned AST is const as the logger uses this to determine line
/// and column numbers of errors/warnings in later stages. If you need to
/// modify the tree, take a copy.
///
/// @return A shared pointer to a valid const AST. Can be a nullptr on error.
/// @todo In the future it may be useful for ::parse to return as much of
/// the valid AST that exists.
///
/// @param code The code to parse
/// @param logger The logger to collect syntax errors
///
OPENVDB_AX_API openvdb::ax::ast::Tree::ConstPtr
parse(const char* code, ax::Logger& logger);
/// @brief Construct an abstract syntax tree from a code snippet.
/// @details A runtime exception will be thrown with the first syntax error.
///
/// @return A shared pointer to a valid AST.
///
/// @param code The code to parse
///
OPENVDB_AX_API openvdb::ax::ast::Tree::Ptr
parse(const char* code);
} // namespace ast
} // namespace ax
} // namespace OPENVDB_VERSION_NAME
} // namespace openvdb
#endif // OPENVDB_AX_AST_HAS_BEEN_INCLUDED
AST.h
Provides the definition for every abstract and concrete derived class which represent a particular ab...
Logger.h
Logging system to collect errors and warnings throughout the different stages of parsing and compilat...
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