diff --git a/cmake/ADIOSBisonFlexSub.cmake b/cmake/ADIOSBisonFlexSub.cmake new file mode 100644 index 0000000000..2a95e1bbcd --- /dev/null +++ b/cmake/ADIOSBisonFlexSub.cmake @@ -0,0 +1,15 @@ +FUNCTION (SETUP_ADIOS_BISON_FLEX_SUB) + +set (BISON_FLEX_PRECOMPILE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/toolkit/derived/parser/pregen-source") + +ADD_CUSTOM_COMMAND(OUTPUT parser.cpp + COMMAND ${CMAKE_COMMAND} -E copy ${BISON_FLEX_PRECOMPILE_DIR}/parser.cpp ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} -E copy ${BISON_FLEX_PRECOMPILE_DIR}/parser.h ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} -E copy ${BISON_FLEX_PRECOMPILE_DIR}/location.hh ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Using pre-generated Bison Output from ${BISON_FLEX_PRECOMPILE_DIR}") +ADD_CUSTOM_COMMAND(OUTPUT lexer.cpp + COMMAND ${CMAKE_COMMAND} -E copy ${BISON_FLEX_PRECOMPILE_DIR}/lexer.cpp ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Using pre-generated Flex Output from ${BISON_FLEX_PRECOMPILE_DIR}") + +set (BISON_Parser_OUTPUT_SOURCE parser.cpp PARENT_SCOPE) +ENDFUNCTION() diff --git a/scripts/ci/scripts/run-clang-format.sh b/scripts/ci/scripts/run-clang-format.sh index c37ab4444d..b85f7fa636 100755 --- a/scripts/ci/scripts/run-clang-format.sh +++ b/scripts/ci/scripts/run-clang-format.sh @@ -12,7 +12,7 @@ then fi # Check C and C++ code with clang-format -find source plugins testing examples bindings -regextype posix-extended -iregex '.*\.(h|c|cpp|tcc|cu)' | xargs clang-format -i +find source plugins testing examples bindings -regextype posix-extended -iregex '.*\.(h|c|cpp|tcc|cu)' ! -path "source/adios2/toolkit/derived/parser/pregen-source/*" | xargs clang-format -i DIFF="$(git diff)" if [ -n "${DIFF}" ] then diff --git a/source/adios2/CMakeLists.txt b/source/adios2/CMakeLists.txt index c4f8d893d2..ff1645b4bb 100644 --- a/source/adios2/CMakeLists.txt +++ b/source/adios2/CMakeLists.txt @@ -135,12 +135,51 @@ if (ADIOS2_HAVE_Derived_Variable) toolkit/derived/Expression.cpp toolkit/derived/Function.cpp toolkit/derived/Function.tcc toolkit/derived/ExprHelper.h) + set_target_properties(adios2_core PROPERTIES + INCLUDE_DIRECTORIES "$;$") + find_package(BISON "3.8.2") + find_package(FLEX) + + if(NOT BISON_FOUND OR NOT FLEX_FOUND) + include(ADIOSBisonFlexSub) + SETUP_ADIOS_BISON_FLEX_SUB() + else() + BISON_TARGET(MyParser + toolkit/derived/parser/parser.y + ${CMAKE_CURRENT_BINARY_DIR}/parser.cpp + COMPILE_FLAGS "-o parser.cpp --header=parser.h" + DEFINES_FILE ${CMAKE_CURRENT_BINARY_DIR}/parser.h) + FLEX_TARGET(MyScanner + toolkit/derived/parser/lexer.l + COMPILE_FLAGS "-o lexer.cpp --header-file=lexer.h" + ${CMAKE_CURRENT_BINARY_DIR}/lexer.cpp + DEFINES_FILE ${CMAKE_CURRENT_BINARY_DIR}/lexer.h) + ADD_FLEX_BISON_DEPENDENCY(MyScanner MyParser) + endif() + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/lexer.cpp PROPERTIES COMPILE_FLAGS -Wno-sign-compare) + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/parser.cpp PROPERTIES COMPILE_FLAGS -Wno-unused-but-set-variable) + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM") + SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/parser.cpp PROPERTIES COMPILE_FLAGS -Wno-unused-but-set-variable) + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + SET_SOURCE_FILES_PROPERTIES(toolkit/derived/Expression.cpp toolkit/derived/Function.cpp PROPERTIES COMPILE_FLAGS "/wd4005 /wd4065 /wd4267 -DYY_NO_UNISTD_H") + endif() add_library(adios2_core_derived - toolkit/derived/parser/lexer.cpp - toolkit/derived/parser/parser.cpp + ${CMAKE_CURRENT_BINARY_DIR}/lexer.cpp + ${CMAKE_CURRENT_BINARY_DIR}/parser.cpp + toolkit/derived/parser/ASTDriver.cpp toolkit/derived/parser/ASTNode.cpp) + set_target_properties(adios2_core_derived PROPERTIES + VISIBILITY_INLINES_HIDDEN ON + INCLUDE_DIRECTORIES "$;$" + EXPORT_NAME core_derived + OUTPUT_NAME adios2${ADIOS2_LIBRARY_SUFFIX}_core_derived) target_link_libraries(adios2_core PRIVATE adios2_core_derived) set(maybe_adios2_core_derived adios2_core_derived) + if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + set_target_properties(adios2_core_derived PROPERTIES COMPILE_FLAGS "/wd4005 /wd4267 /wd4065 -DYY_NO_UNISTD_H") + endif() endif() set(maybe_adios2_core_cuda) diff --git a/source/adios2/core/VariableDerived.cpp b/source/adios2/core/VariableDerived.cpp index 670ad0bc35..07819bf00e 100644 --- a/source/adios2/core/VariableDerived.cpp +++ b/source/adios2/core/VariableDerived.cpp @@ -11,7 +11,7 @@ VariableDerived::VariableDerived(const std::string &name, adios2::derived::Expre const DerivedVarType varType) : VariableBase(name, exprType, helper::GetDataTypeSize(exprType), expr.GetShape(), expr.GetStart(), expr.GetCount(), isConstant), - m_Expr(expr), m_DerivedType(varType) + m_DerivedType(varType), m_Expr(expr) { } @@ -27,15 +27,15 @@ void VariableDerived::UpdateExprDim(std::map> -VariableDerived::ApplyExpression(std::map NameToMVI) +VariableDerived::ApplyExpression(std::map> &NameToMVI) { size_t numBlocks = 0; // check that all variables have the same number of blocks - for (auto variable : NameToMVI) + for (const auto &variable : NameToMVI) { if (numBlocks == 0) - numBlocks = variable.second.BlocksInfo.size(); - if (numBlocks != variable.second.BlocksInfo.size()) + numBlocks = variable.second->BlocksInfo.size(); + if (numBlocks != variable.second->BlocksInfo.size()) helper::Throw("Core", "VariableDerived", "ApplyExpression", " variables do not have the same number of blocks " " in computing the derived variable " + @@ -44,7 +44,7 @@ VariableDerived::ApplyExpression(std::map NameToMVI) std::map> inputData; // create the map between variable name and DerivedData object - for (auto variable : NameToMVI) + for (const auto &variable : NameToMVI) { // add the dimensions of all blocks into a vector std::vector varData; @@ -52,13 +52,13 @@ VariableDerived::ApplyExpression(std::map NameToMVI) { Dims start; Dims count; - for (size_t d = 0; d < variable.second.Dims; d++) + for (int d = 0; d < variable.second->Dims; d++) { - start.push_back(variable.second.BlocksInfo[i].Start[d]); - count.push_back(variable.second.BlocksInfo[i].Count[d]); + start.push_back(variable.second->BlocksInfo[i].Start[d]); + count.push_back(variable.second->BlocksInfo[i].Count[d]); } varData.push_back(adios2::derived::DerivedData( - {variable.second.BlocksInfo[i].BufferP, start, count})); + {variable.second->BlocksInfo[i].BufferP, start, count})); } inputData.insert({variable.first, varData}); } diff --git a/source/adios2/core/VariableDerived.h b/source/adios2/core/VariableDerived.h index 2ff9eb3903..cc7bf8cbf2 100644 --- a/source/adios2/core/VariableDerived.h +++ b/source/adios2/core/VariableDerived.h @@ -32,7 +32,7 @@ class VariableDerived : public VariableBase ApplyExpression(std::map> NameToData, std::map> NameToDims); std::vector> - ApplyExpression(std::map mvi); + ApplyExpression(std::map> &mvi); }; } // end namespace core diff --git a/source/adios2/engine/bp5/BP5Writer.cpp b/source/adios2/engine/bp5/BP5Writer.cpp index 78c0646e6b..ff1889577e 100644 --- a/source/adios2/engine/bp5/BP5Writer.cpp +++ b/source/adios2/engine/bp5/BP5Writer.cpp @@ -516,7 +516,7 @@ void BP5Writer::ComputeDerivedVariables() auto derivedVar = dynamic_cast((*it).second.get()); std::vector varList = derivedVar->VariableNameList(); // to create a mapping between variable name and the varInfo (dim and data pointer) - std::map nameToVarInfo; + std::map> nameToVarInfo; bool computeDerived = true; for (auto varName : varList) { @@ -536,7 +536,7 @@ void BP5Writer::ComputeDerivedVariables() std::cout << " .. skip derived variable " << (*it).second->m_Name << std::endl; break; } - nameToVarInfo.insert({varName, *mvi}); + nameToVarInfo.insert({varName, std::unique_ptr(mvi)}); } // skip computing derived variables if it contains variables that are not written this step if (!computeDerived) diff --git a/source/adios2/toolkit/derived/ExprHelper.h b/source/adios2/toolkit/derived/ExprHelper.h index c72888f95f..e1d31b8bff 100644 --- a/source/adios2/toolkit/derived/ExprHelper.h +++ b/source/adios2/toolkit/derived/ExprHelper.h @@ -57,4 +57,4 @@ inline ExpressionOperator get_op(std::string op) { return string_to_op.at(op); } } } -#endif \ No newline at end of file +#endif diff --git a/source/adios2/toolkit/derived/Expression.cpp b/source/adios2/toolkit/derived/Expression.cpp index d773236526..81db7ccd15 100644 --- a/source/adios2/toolkit/derived/Expression.cpp +++ b/source/adios2/toolkit/derived/Expression.cpp @@ -2,19 +2,35 @@ #define ADIOS2_DERIVED_Expression_CPP_ #include "Expression.h" -#include "parser/ASTNode.h" -#include "parser/parser.h" +#include "parser/ASTDriver.h" namespace adios2 { namespace detail { +// helper function +adios2::detail::ExpressionOperator convert_op(std::string opname) +{ + adios2::detail::ExpressionOperator op; + try + { + op = adios2::detail::get_op(opname); + } + catch (std::out_of_range &e) + { + (void)e; // use e + helper::Throw("Derived", "ExprHelper", "get_op", + "Parser cannot recognize operator '" + opname + "'."); + } + return op; +}; + adios2::derived::ExpressionTree ASTNode_to_ExpressionTree(adios2::detail::ASTNode *node) { - adios2::derived::ExpressionTree exprTree_node(node->operation); - for (adios2::detail::ASTNode *e : node->sub_expr) + adios2::derived::ExpressionTree exprTree_node(convert_op(node->get_opname())); + for (adios2::detail::ASTNode *e : node->get_subexprs()) { - switch (e->operation) + switch (convert_op(e->get_opname())) { case adios2::detail::ExpressionOperator::OP_ALIAS: // add variable given by alias // add an index operation in the chain if the variable contains indeces @@ -25,19 +41,19 @@ adios2::derived::ExpressionTree ASTNode_to_ExpressionTree(adios2::detail::ASTNod index_expr.add_child(e->lookup_var_path(e->alias)); expTree_node->add_child(expr); }*/ - exprTree_node.add_child(e->lookup_var_path(e->alias)); + exprTree_node.add_child(e->get_varname()); break; case adios2::detail::ExpressionOperator::OP_PATH: // add variable name - exprTree_node.add_child(e->alias); + exprTree_node.add_child(e->get_varname()); break; case adios2::detail::ExpressionOperator::OP_NUM: // set the base value for the operation - exprTree_node.set_base(e->value); + exprTree_node.set_base(e->get_value()); break; default: // if the children nodes are other expressions, convert them to expressions auto temp_node = ASTNode_to_ExpressionTree(e); // move from a binary to a multinary tree if the child has the same operation - if (e->operation == node->operation && - adios2::detail::op_property.at(e->operation).is_associative) + if (convert_op(e->get_opname()) == convert_op(node->get_opname()) && + adios2::detail::op_property.at(convert_op(e->get_opname())).is_associative) { // concatenate exprTree with temp_node for (std::tuple childTree : @@ -63,10 +79,10 @@ namespace derived { Expression::Expression(std::string string_exp) -: ExprString(string_exp), m_Shape({0}), m_Start({0}), m_Count({0}) +: m_Shape({0}), m_Start({0}), m_Count({0}), ExprString(string_exp) { - adios2::detail::ASTNode *root_node = adios2::detail::parse_expression(string_exp); - m_Expr = adios2::detail::ASTNode_to_ExpressionTree(root_node); + adios2::detail::ASTDriver drv(string_exp); + m_Expr = adios2::detail::ASTNode_to_ExpressionTree(drv.getAST()); } std::vector Expression::VariableNameList() { return m_Expr.VariableNameList(); } diff --git a/source/adios2/toolkit/derived/Expression.h b/source/adios2/toolkit/derived/Expression.h index 6f60f1c262..2b6f8912a3 100644 --- a/source/adios2/toolkit/derived/Expression.h +++ b/source/adios2/toolkit/derived/Expression.h @@ -34,7 +34,7 @@ class ExpressionTree std::vector> sub_exprs; OpInfo detail; - ExpressionTree(){}; + ExpressionTree() : detail({adios2::detail::ExpressionOperator::OP_NULL, {}, 0}) {} ExpressionTree(adios2::detail::ExpressionOperator o) : detail({o, {}, 0}) {} ExpressionTree(adios2::detail::ExpressionOperator o, double c) : detail({o, {}, 0}) {} ExpressionTree(std::vector> indices) diff --git a/source/adios2/toolkit/derived/Function.cpp b/source/adios2/toolkit/derived/Function.cpp index c524ac8c15..cb145d8927 100644 --- a/source/adios2/toolkit/derived/Function.cpp +++ b/source/adios2/toolkit/derived/Function.cpp @@ -39,7 +39,7 @@ DerivedData MagnitudeFunc(std::vector inputData, DataType type) T *magValues = ApplyOneToOne(inputData, dataSize, [](T a, T b) { return a + b * b; }); \ for (size_t i = 0; i < dataSize; i++) \ { \ - magValues[i] = std::sqrt(magValues[i]); \ + magValues[i] = (T)std::sqrt(magValues[i]); \ } \ return DerivedData({(void *)magValues, inputData[0].Start, inputData[0].Count}); \ } diff --git a/source/adios2/toolkit/derived/Function.tcc b/source/adios2/toolkit/derived/Function.tcc index 1c47c1665b..077ad1e933 100644 --- a/source/adios2/toolkit/derived/Function.tcc +++ b/source/adios2/toolkit/derived/Function.tcc @@ -22,7 +22,7 @@ T *ApplyOneToOne(std::vector inputData, size_t dataSize, std::cout << "Allocation failed for the derived data" << std::endl; // TODO - throw an exception } - memset(outValues, 0, dataSize * sizeof(T)); + memset((void *)outValues, 0, dataSize * sizeof(T)); for (auto &variable : inputData) { for (size_t i = 0; i < dataSize; i++) diff --git a/source/adios2/toolkit/derived/parser/ASTDriver.cpp b/source/adios2/toolkit/derived/parser/ASTDriver.cpp new file mode 100644 index 0000000000..53871e0db8 --- /dev/null +++ b/source/adios2/toolkit/derived/parser/ASTDriver.cpp @@ -0,0 +1,101 @@ +#include "ASTDriver.h" + +namespace adios2 +{ +namespace detail +{ + +using indx_type = std::vector>; + +ASTDriver::ASTDriver() {} + +ASTDriver::ASTDriver(const std::string input) { ASTDriver::parse(input); } + +ASTDriver::~ASTDriver() +{ + while (holding.size() > 0) + { + delete holding.top(); + holding.pop(); + } +} + +ASTNode *ASTDriver::getAST() +{ + // TODO: check only one ASTNode remains in holding + // else throw error that parsing failed + resolve(holding.top()); + return holding.top(); +} + +void ASTDriver::resolve(ASTNode *node) +{ + if (!node->get_alias().empty()) + { + std::tuple var_info; + var_info = lookup_var(node->get_alias()); + node->set_varname(std::get<0>(var_info)); + node->set_indices(std::get<1>(var_info)); + } + for (ASTNode *subexpr : node->get_subexprs()) + { + resolve(subexpr); + } +} + +std::tuple ASTDriver::lookup_var(const std::string alias) +{ + return aliases[alias]; +} + +std::string ASTDriver::lookup_var_name(const std::string alias) +{ + std::tuple var = aliases[alias]; + return std::get<0>(var); +} + +indx_type ASTDriver::lookup_var_indices(const std::string alias) +{ + std::tuple var = aliases[alias]; + return std::get<1>(var); +} + +void ASTDriver::add_lookup_entry(std::string alias, std::string var_name, indx_type indices) +{ + aliases.insert({alias, {var_name, indices}}); +} + +void ASTDriver::add_lookup_entry(std::string alias, std::string var_name) +{ + aliases.insert({alias, {var_name, {}}}); +} + +void ASTDriver::createNode(std::string op_name, size_t numsubexprs) +{ + ASTNode *node = new ASTNode(op_name, numsubexprs); + for (size_t i = 1; i <= numsubexprs; ++i) + { + // TODO: check that holding contains ASTNode(s) + // else throw error that parsing failed + ASTNode *subexpr = holding.top(); + node->insert_subexpr_n(subexpr, numsubexprs - i); + holding.pop(); + } + holding.push(node); +} + +void ASTDriver::createNode(std::string alias) +{ + ASTNode *node = new ASTNode("ALIAS", alias); + holding.push(node); +} + +void ASTDriver::createNode(std::string alias, indx_type indices) +{ + ASTNode *node = new ASTNode("INDEX", indices); + node->pushback_subexpr(new ASTNode("ALIAS", alias)); + holding.push(node); +} + +} +} diff --git a/source/adios2/toolkit/derived/parser/ASTDriver.h b/source/adios2/toolkit/derived/parser/ASTDriver.h new file mode 100644 index 0000000000..c1f2855800 --- /dev/null +++ b/source/adios2/toolkit/derived/parser/ASTDriver.h @@ -0,0 +1,65 @@ +#ifndef ASTDRIVER_HH_ +#define ASTDRIVER_HH_ + +#include "ASTNode.h" +#include "parser.h" +#include +#include +#include +#include + +#define YY_DECL adios2::detail::parser::symbol_type yylex(adios2::detail::ASTDriver &drv) +YY_DECL; + +namespace adios2 +{ +namespace detail +{ + +using indx_type = std::vector>; + +class ASTDriver +{ +public: + ASTDriver(); + ASTDriver(const std::string input); + ~ASTDriver(); + + // Defined in lexer.l + void parse(const std::string input); + + ASTNode *getAST(); + + void resolve(ASTNode *node); + + std::tuple lookup_var(const std::string alias); + std::string lookup_var_name(const std::string alias); + indx_type lookup_var_indices(const std::string alias); + + void add_lookup_entry(std::string alias, std::string var_name, indx_type indices); + void add_lookup_entry(std::string alias, std::string var_name); + + void createNode(std::string, size_t); + void createNode(std::string); + void createNode(std::string, indx_type); + + // Whether to generate parser debug traces. + bool trace_parsing = false; + // Whether to generate scanner debug traces. + bool trace_scanning = false; + // The token's location used by the scanner. + adios2::detail::location location; + +private: + // While parsing, holds ASTNodes until parent node is created + // (since root node is created last from bottom up design) + std::stack holding; + + // Variable lookup table: maps alias names + // to variable names and indices from alias definition + std::map> aliases; +}; + +} +} +#endif // ! ASTDRIVER_HH_ diff --git a/source/adios2/toolkit/derived/parser/ASTNode.cpp b/source/adios2/toolkit/derived/parser/ASTNode.cpp index 5cbc07322d..3563a4c78f 100644 --- a/source/adios2/toolkit/derived/parser/ASTNode.cpp +++ b/source/adios2/toolkit/derived/parser/ASTNode.cpp @@ -1,6 +1,3 @@ -#ifndef ADIOS2_DERIVED_PARSER_ASTNODE_CPP_ -#define ADIOS2_DERIVED_PARSER_ASTNODE_CPP_ - #include "ASTNode.h" namespace adios2 @@ -8,136 +5,92 @@ namespace adios2 namespace detail { -/*****************************************/ -// alias maps to pair of path and indices (indices may be empty string) -std::map> ASTNode::var_lookup; - ASTNode::ASTNode() {} -ASTNode::ASTNode(ExpressionOperator op) : operation(op) {} - -ASTNode::ASTNode(ExpressionOperator op, const char *str) : operation(op) -{ - switch (operation) - { - case ExpressionOperator::OP_ALIAS: - alias = str; - break; - case ExpressionOperator::OP_PATH: - alias = str; - break; - case ExpressionOperator::OP_INDEX: - indices = str; - break; - default: - // TODO: Make some error - // std::cout << "***That's a problem... ASTNode constructed with string should be alias - // type, path type, or index type\n"; - break; - } -} - -ASTNode::ASTNode(ExpressionOperator op, double val) : operation(op), value(val) {} +ASTNode::ASTNode(std::string op) { opname = op; } -ASTNode::ASTNode(ExpressionOperator op, ASTNode *e) : operation(op) { sub_expr.push_back(e); } - -// for index -ASTNode::ASTNode(ExpressionOperator op, ASTNode *e, const char *str) : operation(op), indices(str) +ASTNode::ASTNode(std::string op, size_t numsubexprs) { - sub_expr.push_back(e); + opname = op; + sub_exprs.resize(numsubexprs); } -ASTNode::ASTNode(ExpressionOperator op, ASTNode *e1, ASTNode *e2) : operation(op) +ASTNode::ASTNode(std::string op, std::string a) { - sub_expr.push_back(e1); - sub_expr.push_back(e2); + opname = op; + alias = a; } -// Copy constructor -ASTNode::ASTNode(const ASTNode &e) -: operation(e.operation), alias(e.alias), value(e.value), sub_expr(e.sub_expr) +ASTNode::ASTNode(std::string op, std::vector> i) { + opname = op; + indices = i; } ASTNode::~ASTNode() { - for (ASTNode *e : sub_expr) + for (ASTNode *sub_expr : sub_exprs) { - delete e; + delete sub_expr; } + sub_exprs.clear(); } -std::pair ASTNode::lookup_var(const std::string var_alias) -{ - return var_lookup[var_alias]; -} - -std::string ASTNode::lookup_var_path(const std::string var_alias) -{ - return var_lookup[var_alias].first; -} - -std::string ASTNode::lookup_var_indices(const std::string var_alias) -{ - return var_lookup[var_alias].second; -} - -void ASTNode::add_lookup_entry(const std::string alias, const std::string var_name, - const std::string indices) -{ - // std::cout << "Adding alias to lookup table:\n\talias: " << alias << "\n\tvar_name: " << - // var_name << "\n\tindices: " << indices << std::endl; - var_lookup[alias] = std::make_pair(var_name, indices); -} - -void ASTNode::add_subexpr(ASTNode *e) { sub_expr.push_back(e); } +void ASTNode::set_num_subexprs(size_t n) { sub_exprs.resize(n); } -void ASTNode::add_back_subexpr(ASTNode *e, size_t n) -{ - size_t index = sub_expr.size() - n; - // std::cout << "ASTNode add_back_subexpr index: " << index << std::endl; - // if (index > 0 && sub_expr[index] == nullptr) - sub_expr[index] = e; -} +void ASTNode::pushback_subexpr(ASTNode *subexpr) { sub_exprs.push_back(subexpr); } -void ASTNode::extend_subexprs(size_t n) -{ - // std::cout << "ASTNode extending subexprs from size " << sub_expr.size() << " to " << - // (sub_expr.size() + n) << std::endl; - sub_expr.resize(sub_expr.size() + n); -} +void ASTNode::insert_subexpr_n(ASTNode *subexpr, size_t index) { sub_exprs[index] = subexpr; } -void ASTNode::printpretty(std::string indent) +std::string ASTNode::printpretty(std::string indent) { - std::cout << indent << get_op_name(operation) << ":"; - if (operation == ExpressionOperator::OP_ALIAS) + std::string result = indent + "Node: " + opname + "\n"; + if (!alias.empty()) { - std::cout << " (alias " << alias << " maps to Variable '"; - std::cout << lookup_var_path(alias) << "'"; - if (lookup_var_indices(alias) != "") - { - std::cout << " [" << lookup_var_indices(alias) << "]"; - } - std::cout << ")"; + result += indent + " (alias: \"" + alias + "\")\n"; } - else if (operation == ExpressionOperator::OP_PATH) + if (!varname.empty()) { - std::cout << " (" << alias << ")"; + result += indent + " (varname: \"" + varname + "\")\n"; } - else if (operation == ExpressionOperator::OP_INDEX) + else if (!alias.empty()) { - std::cout << " [" << indices << "]"; + result += indent + " (varname not found)\n"; + } + if (!indices.empty()) + { + result += indent + " (indices: [ "; + for (std::tuple idx : indices) + { + result += std::to_string(std::get<0>(idx)) + ":"; + result += std::to_string(std::get<1>(idx)) + ":"; + result += std::to_string(std::get<2>(idx)) + " "; + } + result += "] )\n"; } - std::cout << std::endl; - for (ASTNode *e : sub_expr) + for (ASTNode *node : sub_exprs) { - if (e != nullptr) - e->printpretty(indent + " "); - else - std::cout << "sub_expr is nullptr" << std::endl; + result += node->printpretty(indent + " "); } + + return result; } +std::vector ASTNode::get_subexprs() { return sub_exprs; } + +std::string ASTNode::get_opname() { return opname; } + +std::string ASTNode::get_alias() { return alias; } + +std::string ASTNode::get_varname() { return varname; } + +std::vector> ASTNode::get_indices() { return indices; } + +double ASTNode::get_value() { return value; } + +void ASTNode::set_varname(const std::string s) { varname = s; } + +void ASTNode::set_indices(const std::vector> idx) { indices = idx; } + } } -#endif diff --git a/source/adios2/toolkit/derived/parser/ASTNode.h b/source/adios2/toolkit/derived/parser/ASTNode.h index 72cec1a812..1d83ab5855 100644 --- a/source/adios2/toolkit/derived/parser/ASTNode.h +++ b/source/adios2/toolkit/derived/parser/ASTNode.h @@ -1,15 +1,9 @@ -#ifndef ADIOS2_DERIVED_PARSER_ASTNODE_H_ -#define ADIOS2_DERIVED_PARSER_ASTNODE_H_ - -#include -#include +#ifndef ASTNODE_HH +#define ASTNODE_HH #include +#include #include -#include "../ExprHelper.h" - -/*****************************************/ - namespace adios2 { namespace detail @@ -19,40 +13,36 @@ class ASTNode { public: ASTNode(); - ASTNode(ExpressionOperator); - ASTNode(ExpressionOperator, const char *a); - ASTNode(ExpressionOperator, double val); - ASTNode(ExpressionOperator, ASTNode *e); - ASTNode(ExpressionOperator, ASTNode *e, const char *i); - ASTNode(ExpressionOperator, ASTNode *e1, ASTNode *e2); - - // Copy constructor - ASTNode(const ASTNode &e); - + ASTNode(std::string); + ASTNode(std::string, size_t); + ASTNode(std::string, std::string); + ASTNode(std::string, std::vector>); ~ASTNode(); - static std::pair lookup_var(const std::string var_alias); - static std::string lookup_var_path(const std::string var_alias); - static std::string lookup_var_indices(const std::string var_alias); - static void add_lookup_entry(const std::string alias, const std::string var_name, - const std::string indices); + void set_num_subexprs(size_t); + void pushback_subexpr(ASTNode *); + void insert_subexpr_n(ASTNode *, size_t); + std::string printpretty(std::string = ""); + + std::vector get_subexprs(); + std::string get_opname(); + std::string get_alias(); + std::string get_varname(); + std::vector> get_indices(); + double get_value(); - void add_subexpr(ASTNode *e); - void add_back_subexpr(ASTNode *e, size_t i); - void extend_subexprs(size_t n); - void infer_type(); - void printpretty(std::string indent = ""); + void set_varname(const std::string); + void set_indices(const std::vector>); - // private: - ExpressionOperator operation; +private: + std::vector sub_exprs; + std::string opname; std::string alias; - std::string indices; + std::string varname; + std::vector> indices; double value; - std::vector sub_expr; - - static std::map> var_lookup; }; } } -#endif \ No newline at end of file +#endif // ! ASTNODE_HH diff --git a/source/adios2/toolkit/derived/parser/lexer.cpp b/source/adios2/toolkit/derived/parser/lexer.cpp deleted file mode 100644 index 03b101c191..0000000000 --- a/source/adios2/toolkit/derived/parser/lexer.cpp +++ /dev/null @@ -1,1884 +0,0 @@ -#line 1 "lexer.cpp" - -#line 3 "lexer.cpp" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 6 -#define YY_FLEX_SUBMINOR_VERSION 4 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include -#include -#include -#include - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -typedef uint64_t flex_uint64_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767 - 1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647 - 1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#ifndef SIZE_MAX -#define SIZE_MAX (~(size_t)0) -#endif - -#endif /* ! C99 */ - -#endif /* ! FLEXINT_H */ - -/* begin standard C++ headers. */ - -/* TODO: this is always defined, so inline it */ -#define yyconst const - -#if defined(__GNUC__) && __GNUC__ >= 3 -#define yynoreturn __attribute__((__noreturn__)) -#else -#define yynoreturn -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an - * integer in range [0..255] for use as an array index. - */ -#define YY_SC_TO_UI(c) ((YY_CHAR)(c)) - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN (yy_start) = 1 + 2 * -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START (((yy_start)-1) / 2) -#define YYSTATE YY_START -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart(yyin) -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else -#define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ -#endif - -/* The state buf must be large enough to hold one state per character in the main buffer. - */ -#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -extern yy_size_t yyleng; - -extern FILE *yyin, *yyout; - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - -#define YY_LESS_LINENO(n) -#define YY_LINENO_REWIND_TO(ptr) - -/* Return all but the first "n" matched characters back to the input stream. */ -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg); \ - *yy_cp = (yy_hold_char); \ - YY_RESTORE_YY_MORE_OFFSET(yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } while (0) -#define unput(c) yyunput(c, (yytext_ptr)) - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state -{ - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - int yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - yy_size_t yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 -}; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -/* Stack of input buffers. */ -static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ -static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ -static YY_BUFFER_STATE *yy_buffer_stack = NULL; /**< Stack as an array. */ - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - * - * Returns the top of the stack, or NULL. - */ -#define YY_CURRENT_BUFFER ((yy_buffer_stack) ? (yy_buffer_stack)[(yy_buffer_stack_top)] : NULL) -/* Same as previous macro, but useful when we know that the buffer stack is not - * NULL or when we need an lvalue. For internal use only. - */ -#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] - -/* yy_hold_char holds the character lost when yytext is formed. */ -static char yy_hold_char; -static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */ -yy_size_t yyleng; - -/* Points to current character in buffer. */ -static char *yy_c_buf_p = NULL; -static int yy_init = 0; /* whether we need to initialize */ -static int yy_start = 0; /* start state number */ - -/* Flag which is used to allow yywrap()'s to do buffer switches - * instead of setting up a fresh yyin. A bit of a hack ... - */ -static int yy_did_buffer_switch_on_eof; - -void yyrestart(FILE *input_file); -void yy_switch_to_buffer(YY_BUFFER_STATE new_buffer); -YY_BUFFER_STATE yy_create_buffer(FILE *file, int size); -void yy_delete_buffer(YY_BUFFER_STATE b); -void yy_flush_buffer(YY_BUFFER_STATE b); -void yypush_buffer_state(YY_BUFFER_STATE new_buffer); -void yypop_buffer_state(void); - -static void yyensure_buffer_stack(void); -static void yy_load_buffer_state(void); -static void yy_init_buffer(YY_BUFFER_STATE b, FILE *file); -#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER) - -YY_BUFFER_STATE yy_scan_buffer(char *base, yy_size_t size); -YY_BUFFER_STATE yy_scan_string(const char *yy_str); -YY_BUFFER_STATE yy_scan_bytes(const char *bytes, yy_size_t len); - -void *yyalloc(yy_size_t); -void *yyrealloc(void *, yy_size_t); -void yyfree(void *); - -#define yy_new_buffer yy_create_buffer -#define yy_set_interactive(is_interactive) \ - { \ - if (!YY_CURRENT_BUFFER) \ - { \ - yyensure_buffer_stack(); \ - YY_CURRENT_BUFFER_LVALUE = yy_create_buffer(yyin, YY_BUF_SIZE); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } -#define yy_set_bol(at_bol) \ - { \ - if (!YY_CURRENT_BUFFER) \ - { \ - yyensure_buffer_stack(); \ - YY_CURRENT_BUFFER_LVALUE = yy_create_buffer(yyin, YY_BUF_SIZE); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } -#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) - -/* Begin user sect3 */ - -#define yywrap() (/*CONSTCOND*/ 1) -#define YY_SKIP_YYWRAP -typedef flex_uint8_t YY_CHAR; - -FILE *yyin = NULL, *yyout = NULL; - -typedef int yy_state_type; - -extern int yylineno; -int yylineno = 1; - -extern char *yytext; -#ifdef yytext_ptr -#undef yytext_ptr -#endif -#define yytext_ptr yytext - -static yy_state_type yy_get_previous_state(void); -static yy_state_type yy_try_NUL_trans(yy_state_type current_state); -static int yy_get_next_buffer(void); -static void yynoreturn yy_fatal_error(const char *msg); - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - (yytext_ptr) = yy_bp; \ - yyleng = (yy_size_t)(yy_cp - yy_bp); \ - (yy_hold_char) = *yy_cp; \ - *yy_cp = '\0'; \ - (yy_c_buf_p) = yy_cp; -#define YY_NUM_RULES 24 -#define YY_END_OF_BUFFER 25 -/* This struct is not used in this scanner, - but its presence is necessary. */ -struct yy_trans_info -{ - flex_int32_t yy_verify; - flex_int32_t yy_nxt; -}; -static const flex_int16_t yy_accept[91] = { - 0, 0, 0, 25, 23, 17, 18, 23, 23, 6, 7, 3, 1, 8, 2, 23, 4, 16, 23, 19, 19, 23, 5, - 19, 19, 19, 19, 19, 18, 17, 0, 0, 0, 16, 16, 16, 19, 19, 0, 20, 19, 0, 0, 19, 19, 19, - 19, 19, 19, 19, 0, 21, 0, 0, 16, 0, 0, 16, 20, 20, 18, 0, 22, 0, 0, 9, 12, 19, 19, - 11, 19, 13, 18, 0, 16, 20, 0, 0, 0, 15, 19, 10, 0, 0, 19, 0, 19, 19, 19, 14, 0}; - -static const YY_CHAR yy_ec[256] = { - 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 4, 1, 1, 5, 6, 7, - 8, 9, 10, 11, 12, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 1, 1, 1, 1, - 1, 1, 16, 16, 16, 16, 17, 18, 16, 16, 16, 16, 16, 16, 16, 16, 19, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 20, 21, 22, 23, 24, 1, 25, 26, 27, 28, - - 29, 26, 30, 26, 31, 26, 26, 32, 33, 34, 35, 26, 36, 37, 38, 39, 40, 26, 26, 26, 26, - 26, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; - -static const YY_CHAR yy_meta[42] = {0, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 3, 4, 5, 6, 1, 6, 6, 6, 6, 1, - 5, 1, 1, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 1}; - -static const flex_int16_t yy_base[98] = { - 0, 0, 0, 221, 254, 218, 254, 190, 29, 254, 254, 254, 254, 254, 254, 203, 254, - 32, 34, 204, 33, 42, 254, 39, 42, 47, 48, 50, 254, 213, 180, 50, 75, 199, - 52, 56, 200, 81, 84, 89, 89, 101, 103, 66, 53, 75, 92, 94, 97, 102, 183, - 254, 116, 128, 118, 134, 196, 112, 140, 144, 196, 105, 254, 145, 152, 195, 193, 138, - 144, 157, 132, 126, 254, 162, 117, 166, 174, 167, 181, 113, 173, 71, 178, 184, 160, - 187, 188, 190, 134, 64, 254, 224, 227, 229, 234, 238, 243, 247 - -}; - -static const flex_int16_t yy_def[98] = { - 0, 90, 1, 90, 90, 90, 90, 90, 91, 90, 90, 90, 90, 90, 90, 90, 90, 92, 93, 92, - 92, 90, 90, 92, 92, 92, 92, 92, 90, 90, 90, 91, 94, 90, 90, 92, 92, 92, 93, 95, - 92, 90, 90, 92, 92, 92, 92, 92, 92, 92, 90, 90, 96, 94, 90, 90, 90, 92, 97, 95, - 92, 90, 90, 90, 90, 92, 92, 92, 92, 92, 92, 92, 90, 96, 90, 97, 90, 90, 90, 92, - 92, 92, 90, 90, 92, 90, 92, 92, 92, 92, 0, 90, 90, 90, 90, 90, 90, 90 - -}; - -static const flex_int16_t yy_nxt[296] = { - 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 19, 21, 4, 4, 22, - 19, 23, 19, 24, 19, 19, 19, 19, 19, 25, 19, 19, 19, 19, 26, 27, 19, 28, 31, 31, 34, 90, 35, 38, - 38, 37, 31, 90, 40, 31, 90, 38, 41, 42, 38, 90, 90, 37, 90, 31, 31, 90, 54, 43, 34, 55, 35, 31, - 46, 37, 31, 49, 90, 44, 90, 47, 51, 55, 45, 90, 48, 37, 52, 90, 52, 52, 56, 66, 56, 90, 65, 57, - 52, 38, 38, 52, 58, - - 90, 58, 58, 90, 38, 90, 60, 38, 90, 58, 61, 67, 58, 90, 41, 42, 63, 64, 76, 77, 51, 68, 62, 90, - 90, 57, 52, 69, 52, 52, 74, 54, 51, 70, 55, 71, 52, 90, 52, 52, 52, 52, 56, 90, 56, 90, 55, 74, - 52, 90, 58, 52, 58, 58, 58, 90, 58, 58, 63, 64, 58, 61, 89, 58, 58, 78, 51, 58, 90, 79, 81, 90, - 52, 62, 52, 52, 58, 80, 58, 58, 82, 83, 52, 61, 90, 52, 58, 76, 77, 58, 61, 82, 83, 61, 78, 62, - 61, 85, 86, 90, - - 85, 90, 62, 84, 90, 62, 90, 90, 62, 74, 72, 90, 33, 50, 29, 90, 33, 88, 30, 29, 90, 90, 90, 90, - 90, 90, 90, 87, 32, 32, 36, 90, 36, 39, 39, 53, 53, 90, 53, 53, 59, 90, 59, 59, 73, 73, 90, 73, - 73, 75, 90, 75, 75, 3, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, - 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90 - -}; - -static const flex_int16_t yy_chk[296] = { - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 8, 8, 17, 20, 17, 18, - 18, 17, 8, 23, 20, 8, 24, 18, 21, 21, 18, 25, 26, 17, 27, 31, 31, 44, 34, 23, 35, 34, 35, 31, - 25, 35, 31, 27, 89, 24, 43, 26, 32, 34, 24, 81, 26, 35, 32, 45, 32, 32, 37, 44, 37, 37, 43, 37, - 32, 38, 38, 32, 39, - - 40, 39, 39, 46, 38, 47, 40, 38, 48, 39, 41, 45, 39, 49, 41, 41, 42, 42, 61, 61, 52, 46, 41, 57, - 79, 57, 52, 47, 52, 52, 74, 54, 53, 48, 54, 49, 52, 71, 53, 52, 53, 53, 55, 70, 55, 88, 54, 55, - 53, 67, 58, 53, 58, 58, 59, 68, 59, 59, 63, 63, 58, 64, 88, 58, 59, 64, 73, 59, 69, 67, 70, 84, - 73, 64, 73, 73, 75, 68, 75, 75, 77, 77, 73, 76, 80, 73, 75, 76, 76, 75, 78, 82, 82, 83, 78, 76, - 85, 83, 84, 86, - - 85, 87, 78, 80, 66, 83, 65, 60, 85, 56, 50, 36, 33, 30, 29, 19, 15, 87, 7, 5, 3, 0, 0, 0, - 0, 0, 0, 86, 91, 91, 92, 0, 92, 93, 93, 94, 94, 0, 94, 94, 95, 0, 95, 95, 96, 96, 0, 96, - 96, 97, 0, 97, 97, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, - 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90 - -}; - -static yy_state_type yy_last_accepting_state; -static char *yy_last_accepting_cpos; - -extern int yy_flex_debug; -int yy_flex_debug = 0; - -/* The intent behind this definition is that it'll catch - * any uses of REJECT which flex missed. - */ -#define REJECT reject_used_but_not_detected -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -char *yytext; -#line 1 "lexer.l" -#line 2 "lexer.l" -#include "parser.h" -#define YY_USER_ACTION yylloc.first_line = yylloc.last_line = yylineno; -#line 544 "lexer.cpp" -#line 545 "lexer.cpp" - -#define INITIAL 0 - -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -static int yy_init_globals(void); - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -int yylex_destroy(void); - -int yyget_debug(void); - -void yyset_debug(int debug_flag); - -YY_EXTRA_TYPE yyget_extra(void); - -void yyset_extra(YY_EXTRA_TYPE user_defined); - -FILE *yyget_in(void); - -void yyset_in(FILE *_in_str); - -FILE *yyget_out(void); - -void yyset_out(FILE *_out_str); - -yy_size_t yyget_leng(void); - -char *yyget_text(void); - -int yyget_lineno(void); - -void yyset_lineno(int _line_number); - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap(void); -#else -extern int yywrap(void); -#endif -#endif - -#ifndef YY_NO_UNPUT - -static void yyunput(int c, char *buf_ptr); - -#endif - -#ifndef yytext_ptr -static void yy_flex_strncpy(char *, const char *, int); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen(const char *); -#endif - -#ifndef YY_NO_INPUT -#ifdef __cplusplus -static int yyinput(void); -#else -static int input(void); -#endif - -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else -#define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ -#endif - -/* Copy whatever the last rule matched to the standard output. */ -#ifndef ECHO -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO \ - do \ - { \ - if (fwrite(yytext, (size_t)yyleng, 1, yyout)) \ - { \ - } \ - } while (0) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf, result, max_size) \ - if (YY_CURRENT_BUFFER_LVALUE->yy_is_interactive) \ - { \ - int c = '*'; \ - yy_size_t n; \ - for (n = 0; n < max_size && (c = getc(yyin)) != EOF && c != '\n'; ++n) \ - buf[n] = (char)c; \ - if (c == '\n') \ - buf[n++] = (char)c; \ - if (c == EOF && ferror(yyin)) \ - YY_FATAL_ERROR("input in flex scanner failed"); \ - result = n; \ - } \ - else \ - { \ - errno = 0; \ - while ((result = (int)fread(buf, 1, (yy_size_t)max_size, yyin)) == 0 && ferror(yyin)) \ - { \ - if (errno != EINTR) \ - { \ - YY_FATAL_ERROR("input in flex scanner failed"); \ - break; \ - } \ - errno = 0; \ - clearerr(yyin); \ - } \ - } - -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error(msg) -#endif - -/* end tables serialization structures and prototypes */ - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int yylex(void); - -#define YY_DECL int yylex(void) -#endif /* !YY_DECL */ - -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK /*LINTED*/ break; -#endif - -#define YY_RULE_SETUP YY_USER_ACTION - -/** The main scanner function which does all the work. - */ -YY_DECL -{ - yy_state_type yy_current_state; - char *yy_cp, *yy_bp; - int yy_act; - - if (!(yy_init)) - { - (yy_init) = 1; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if (!(yy_start)) - (yy_start) = 1; /* first start state */ - - if (!yyin) - yyin = stdin; - - if (!yyout) - yyout = stdout; - - if (!YY_CURRENT_BUFFER) - { - yyensure_buffer_stack(); - YY_CURRENT_BUFFER_LVALUE = yy_create_buffer(yyin, YY_BUF_SIZE); - } - - yy_load_buffer_state(); - } - - { -#line 12 "lexer.l" - -#line 765 "lexer.cpp" - - while (/*CONSTCOND*/ 1) /* loops until end-of-file is reached */ - { - yy_cp = (yy_c_buf_p); - - /* Support of yytext. */ - *yy_cp = (yy_hold_char); - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = (yy_start); - yy_match: - do - { - YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; - if (yy_accept[yy_current_state]) - { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = yy_cp; - } - while (yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state) - { - yy_current_state = (int)yy_def[yy_current_state]; - if (yy_current_state >= 91) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - ++yy_cp; - } while (yy_base[yy_current_state] != 254); - - yy_find_action: - yy_act = yy_accept[yy_current_state]; - if (yy_act == 0) - { /* have to back up */ - yy_cp = (yy_last_accepting_cpos); - yy_current_state = (yy_last_accepting_state); - yy_act = yy_accept[yy_current_state]; - } - - YY_DO_BEFORE_ACTION; - - do_action: /* This label is used only to access EOF actions. */ - - switch (yy_act) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = (yy_hold_char); - yy_cp = (yy_last_accepting_cpos); - yy_current_state = (yy_last_accepting_state); - goto yy_find_action; - - case 1: - YY_RULE_SETUP -#line 14 "lexer.l" - { - yylval.sval = strdup(yytext); - return OPERATOR; - } - YY_BREAK - case 2: - YY_RULE_SETUP -#line 15 "lexer.l" - { - yylval.sval = strdup(yytext); - return OPERATOR; - } - YY_BREAK - case 3: - YY_RULE_SETUP -#line 16 "lexer.l" - { - yylval.sval = strdup(yytext); - return OPERATOR; - } - YY_BREAK - case 4: - YY_RULE_SETUP -#line 17 "lexer.l" - { - yylval.sval = strdup(yytext); - return OPERATOR; - } - YY_BREAK - case 5: - YY_RULE_SETUP -#line 18 "lexer.l" - { - yylval.sval = strdup(yytext); - return OPERATOR; - } - YY_BREAK - case 6: - YY_RULE_SETUP -#line 19 "lexer.l" - { - return L_PAREN; - } - YY_BREAK - case 7: - YY_RULE_SETUP -#line 20 "lexer.l" - { - return R_PAREN; - } - YY_BREAK - case 8: - YY_RULE_SETUP -#line 21 "lexer.l" - { - return COMMA; - } - YY_BREAK - case 9: - YY_RULE_SETUP -#line 22 "lexer.l" - { - yylval.sval = strdup(yytext); - return FUNCTION; - } - YY_BREAK - case 10: - YY_RULE_SETUP -#line 23 "lexer.l" - { - yylval.sval = strdup(yytext); - return FUNCTION; - } - YY_BREAK - case 11: - YY_RULE_SETUP -#line 24 "lexer.l" - { - yylval.sval = strdup(yytext); - return FUNCTION; - } - YY_BREAK - case 12: - YY_RULE_SETUP -#line 25 "lexer.l" - { - yylval.sval = strdup(yytext); - return FUNCTION; - } - YY_BREAK - case 13: - YY_RULE_SETUP -#line 26 "lexer.l" - { - yylval.sval = strdup(yytext); - return FUNCTION; - } - YY_BREAK - case 14: - YY_RULE_SETUP -#line 27 "lexer.l" - { - yylval.sval = strdup(yytext); - return FUNCTION; - } - YY_BREAK - case 15: - YY_RULE_SETUP -#line 28 "lexer.l" - { - yylval.sval = strdup(yytext); - return FUNCTION; - } - YY_BREAK - case 16: - YY_RULE_SETUP -#line 31 "lexer.l" - { - yylval.dval = atof(yytext); - return NUMBER; - } - YY_BREAK - case 17: - YY_RULE_SETUP -#line 33 "lexer.l" - { /* ignore spaces */ - } - YY_BREAK - case 18: - /* rule 18 can match eol */ - YY_RULE_SETUP -#line 35 "lexer.l" - { - return ENDL; - } - YY_BREAK - case 19: - YY_RULE_SETUP -#line 37 "lexer.l" - { - yylval.sval = strdup(yytext); - return ALIAS; - } - YY_BREAK - case 20: - YY_RULE_SETUP -#line 39 "lexer.l" - { - yylval.sval = strndup(yytext + 1, strlen(yytext) - 1); - return PATH; - } - YY_BREAK - case 21: - YY_RULE_SETUP -#line 41 "lexer.l" - { - yylval.sval = strndup(yytext + 1, strlen(yytext) - 2); - return PATH; - } - YY_BREAK - case 22: - YY_RULE_SETUP -#line 43 "lexer.l" - { - yylval.sval = strndup(yytext + 1, strlen(yytext) - 2); - return INDICES; - } - YY_BREAK - case 23: - YY_RULE_SETUP -#line 45 "lexer.l" - { - printf("Error at line %d: unrecognized symbol \"%s\"\n", yylloc.first_line, - yytext); - exit(0); - } - YY_BREAK - case 24: - YY_RULE_SETUP -#line 47 "lexer.l" - ECHO; - YY_BREAK -#line 943 "lexer.cpp" - case YY_STATE_EOF(INITIAL): - yyterminate(); - - case YY_END_OF_BUFFER: { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int)(yy_cp - (yytext_ptr)) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = (yy_hold_char); - YY_RESTORE_YY_MORE_OFFSET - - if (YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yylex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ((yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state(); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans(yy_current_state); - - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - - if (yy_next_state) - { - /* Consume the NUL. */ - yy_cp = ++(yy_c_buf_p); - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = (yy_c_buf_p); - goto yy_find_action; - } - } - - else - switch (yy_get_next_buffer()) - { - case EOB_ACT_END_OF_FILE: { - (yy_did_buffer_switch_on_eof) = 0; - - if (yywrap()) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if (!(yy_did_buffer_switch_on_eof)) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state(); - - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - (yy_c_buf_p) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; - - yy_current_state = yy_get_previous_state(); - - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR("fatal flex scanner internal error--no action found"); - } /* end of action switch */ - } /* end of scanning one token */ - } /* end of user's declarations */ -} /* end of yylex */ - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ -static int yy_get_next_buffer(void) -{ - char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - char *source = (yytext_ptr); - int number_to_move, i; - int ret_val; - - if ((yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1]) - YY_FATAL_ERROR("fatal flex scanner internal error--end of buffer missed"); - - if (YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ((yy_c_buf_p) - (yytext_ptr)-YY_MORE_ADJ == 1) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int)((yy_c_buf_p) - (yytext_ptr)-1); - - for (i = 0; i < number_to_move; ++i) - *(dest++) = *(source++); - - if (YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; - - else - { - yy_size_t num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - - while (num_to_read <= 0) - { /* Not enough room in the buffer - grow it. */ - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; - - int yy_c_buf_p_offset = (int)((yy_c_buf_p)-b->yy_ch_buf); - - if (b->yy_is_our_buffer) - { - yy_size_t new_size = b->yy_buf_size * 2; - - if (new_size <= 0) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yyrealloc((void *)b->yy_ch_buf, (yy_size_t)(b->yy_buf_size + 2)); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = NULL; - - if (!b->yy_ch_buf) - YY_FATAL_ERROR("fatal error - scanner input buffer overflow"); - - (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - } - - if (num_to_read > YY_READ_BUF_SIZE) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT((&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), (yy_n_chars), num_to_read); - - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - if ((yy_n_chars) == 0) - { - if (number_to_move == YY_MORE_ADJ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart(yyin); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) - { - /* Extend the array by 50%, plus the number we really need. */ - yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = - (char *)yyrealloc((void *)YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t)new_size); - if (!YY_CURRENT_BUFFER_LVALUE->yy_ch_buf) - YY_FATAL_ERROR("out of dynamic memory in yy_get_next_buffer()"); - /* "- 2" to take care of EOB's */ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int)(new_size - 2); - } - - (yy_n_chars) += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; - - (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; - - return ret_val; -} - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - -static yy_state_type yy_get_previous_state(void) -{ - yy_state_type yy_current_state; - char *yy_cp; - - yy_current_state = (yy_start); - - for (yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp) - { - YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 41); - if (yy_accept[yy_current_state]) - { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = yy_cp; - } - while (yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state) - { - yy_current_state = (int)yy_def[yy_current_state]; - if (yy_current_state >= 91) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - } - - return yy_current_state; -} - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ -static yy_state_type yy_try_NUL_trans(yy_state_type yy_current_state) -{ - int yy_is_jam; - char *yy_cp = (yy_c_buf_p); - - YY_CHAR yy_c = 41; - if (yy_accept[yy_current_state]) - { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = yy_cp; - } - while (yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state) - { - yy_current_state = (int)yy_def[yy_current_state]; - if (yy_current_state >= 91) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - yy_is_jam = (yy_current_state == 90); - - return yy_is_jam ? 0 : yy_current_state; -} - -#ifndef YY_NO_UNPUT - -static void yyunput(int c, char *yy_bp) -{ - char *yy_cp; - - yy_cp = (yy_c_buf_p); - - /* undo effects of setting up yytext */ - *yy_cp = (yy_hold_char); - - if (yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2) - { /* need to shift things up to make room */ - /* +2 for EOB chars. */ - yy_size_t number_to_move = (yy_n_chars) + 2; - char *dest = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; - char *source = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; - - while (source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf) - *--dest = *--source; - - yy_cp += (int)(dest - source); - yy_bp += (int)(dest - source); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = - (int)YY_CURRENT_BUFFER_LVALUE->yy_buf_size; - - if (yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2) - YY_FATAL_ERROR("flex scanner push-back overflow"); - } - - *--yy_cp = (char)c; - - (yytext_ptr) = yy_bp; - (yy_hold_char) = *yy_cp; - (yy_c_buf_p) = yy_cp; -} - -#endif - -#ifndef YY_NO_INPUT -#ifdef __cplusplus -static int yyinput(void) -#else -static int input(void) -#endif - -{ - int c; - - *(yy_c_buf_p) = (yy_hold_char); - - if (*(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ((yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]) - /* This was really a NUL. */ - *(yy_c_buf_p) = '\0'; - - else - { /* need more input */ - yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); - ++(yy_c_buf_p); - - switch (yy_get_next_buffer()) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - yyrestart(yyin); - - /*FALLTHROUGH*/ - - case EOB_ACT_END_OF_FILE: { - if (yywrap()) - return 0; - - if (!(yy_did_buffer_switch_on_eof)) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(); -#else - return input(); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = (yytext_ptr) + offset; - break; - } - } - } - - c = *(unsigned char *)(yy_c_buf_p); /* cast for 8-bit char's */ - *(yy_c_buf_p) = '\0'; /* preserve yytext */ - (yy_hold_char) = *++(yy_c_buf_p); - - return c; -} -#endif /* ifndef YY_NO_INPUT */ - -/** Immediately switch to a different input stream. - * @param input_file A readable stream. - * - * @note This function does not reset the start condition to @c INITIAL . - */ -void yyrestart(FILE *input_file) -{ - - if (!YY_CURRENT_BUFFER) - { - yyensure_buffer_stack(); - YY_CURRENT_BUFFER_LVALUE = yy_create_buffer(yyin, YY_BUF_SIZE); - } - - yy_init_buffer(YY_CURRENT_BUFFER, input_file); - yy_load_buffer_state(); -} - -/** Switch to a different input buffer. - * @param new_buffer The new input buffer. - * - */ -void yy_switch_to_buffer(YY_BUFFER_STATE new_buffer) -{ - - /* TODO. We should be able to replace this entire function body - * with - * yypop_buffer_state(); - * yypush_buffer_state(new_buffer); - */ - yyensure_buffer_stack(); - if (YY_CURRENT_BUFFER == new_buffer) - return; - - if (YY_CURRENT_BUFFER) - { - /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - YY_CURRENT_BUFFER_LVALUE = new_buffer; - yy_load_buffer_state(); - - /* We don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - (yy_did_buffer_switch_on_eof) = 1; -} - -static void yy_load_buffer_state(void) -{ - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - (yy_hold_char) = *(yy_c_buf_p); -} - -/** Allocate and initialize an input buffer state. - * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * - * @return the allocated buffer state. - */ -YY_BUFFER_STATE yy_create_buffer(FILE *file, int size) -{ - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE)yyalloc(sizeof(struct yy_buffer_state)); - if (!b) - YY_FATAL_ERROR("out of dynamic memory in yy_create_buffer()"); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *)yyalloc((yy_size_t)(b->yy_buf_size + 2)); - if (!b->yy_ch_buf) - YY_FATAL_ERROR("out of dynamic memory in yy_create_buffer()"); - - b->yy_is_our_buffer = 1; - - yy_init_buffer(b, file); - - return b; -} - -/** Destroy the buffer. - * @param b a buffer created with yy_create_buffer() - * - */ -void yy_delete_buffer(YY_BUFFER_STATE b) -{ - - if (!b) - return; - - if (b == YY_CURRENT_BUFFER) /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE)0; - - if (b->yy_is_our_buffer) - yyfree((void *)b->yy_ch_buf); - - yyfree((void *)b); -} - -/* Initializes or reinitializes a buffer. - * This function is sometimes called more than once on the same buffer, - * such as during a yyrestart() or at EOF. - */ -static void yy_init_buffer(YY_BUFFER_STATE b, FILE *file) - -{ - int oerrno = errno; - - yy_flush_buffer(b); - - b->yy_input_file = file; - b->yy_fill_buffer = 1; - - /* If b is the current buffer, then yy_init_buffer was _probably_ - * called from yyrestart() or through yy_get_next_buffer. - * In that case, we don't want to reset the lineno or column. - */ - if (b != YY_CURRENT_BUFFER) - { - b->yy_bs_lineno = 1; - b->yy_bs_column = 0; - } - - b->yy_is_interactive = file ? (isatty(fileno(file)) > 0) : 0; - - errno = oerrno; -} - -/** Discard all buffered characters. On the next scan, YY_INPUT will be called. - * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * - */ -void yy_flush_buffer(YY_BUFFER_STATE b) -{ - if (!b) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if (b == YY_CURRENT_BUFFER) - yy_load_buffer_state(); -} - -/** Pushes the new state onto the stack. The new state becomes - * the current state. This function will allocate the stack - * if necessary. - * @param new_buffer The new state. - * - */ -void yypush_buffer_state(YY_BUFFER_STATE new_buffer) -{ - if (new_buffer == NULL) - return; - - yyensure_buffer_stack(); - - /* This block is copied from yy_switch_to_buffer. */ - if (YY_CURRENT_BUFFER) - { - /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) - (yy_buffer_stack_top)++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; - - /* copied from yy_switch_to_buffer. */ - yy_load_buffer_state(); - (yy_did_buffer_switch_on_eof) = 1; -} - -/** Removes and deletes the top of the stack, if present. - * The next element becomes the new top. - * - */ -void yypop_buffer_state(void) -{ - if (!YY_CURRENT_BUFFER) - return; - - yy_delete_buffer(YY_CURRENT_BUFFER); - YY_CURRENT_BUFFER_LVALUE = NULL; - if ((yy_buffer_stack_top) > 0) - --(yy_buffer_stack_top); - - if (YY_CURRENT_BUFFER) - { - yy_load_buffer_state(); - (yy_did_buffer_switch_on_eof) = 1; - } -} - -/* Allocates the stack if it does not exist. - * Guarantees space for at least one push. - */ -static void yyensure_buffer_stack(void) -{ - yy_size_t num_to_alloc; - - if (!(yy_buffer_stack)) - { - - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. - */ - num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ - (yy_buffer_stack) = - (struct yy_buffer_state **)yyalloc(num_to_alloc * sizeof(struct yy_buffer_state *)); - if (!(yy_buffer_stack)) - YY_FATAL_ERROR("out of dynamic memory in yyensure_buffer_stack()"); - - memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state *)); - - (yy_buffer_stack_max) = num_to_alloc; - (yy_buffer_stack_top) = 0; - return; - } - - if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1) - { - - /* Increase the buffer to prepare for a possible push. */ - yy_size_t grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = (yy_buffer_stack_max) + grow_size; - (yy_buffer_stack) = (struct yy_buffer_state **)yyrealloc( - (yy_buffer_stack), num_to_alloc * sizeof(struct yy_buffer_state *)); - if (!(yy_buffer_stack)) - YY_FATAL_ERROR("out of dynamic memory in yyensure_buffer_stack()"); - - /* zero only the new slots.*/ - memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, - grow_size * sizeof(struct yy_buffer_state *)); - (yy_buffer_stack_max) = num_to_alloc; - } -} - -/** Setup the input buffer state to scan directly from a user-specified character buffer. - * @param base the character buffer - * @param size the size in bytes of the character buffer - * - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_buffer(char *base, yy_size_t size) -{ - YY_BUFFER_STATE b; - - if (size < 2 || base[size - 2] != YY_END_OF_BUFFER_CHAR || - base[size - 1] != YY_END_OF_BUFFER_CHAR) - /* They forgot to leave room for the EOB's. */ - return NULL; - - b = (YY_BUFFER_STATE)yyalloc(sizeof(struct yy_buffer_state)); - if (!b) - YY_FATAL_ERROR("out of dynamic memory in yy_scan_buffer()"); - - b->yy_buf_size = (int)(size - 2); /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = NULL; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - yy_switch_to_buffer(b); - - return b; -} - -/** Setup the input buffer state to scan a string. The next call to yylex() will - * scan from a @e copy of @a str. - * @param yystr a NUL-terminated string to scan - * - * @return the newly allocated buffer state object. - * @note If you want to scan bytes that may contain NUL values, then use - * yy_scan_bytes() instead. - */ -YY_BUFFER_STATE yy_scan_string(const char *yystr) -{ - - return yy_scan_bytes(yystr, (int)strlen(yystr)); -} - -/** Setup the input buffer state to scan the given bytes. The next call to yylex() will - * scan from a @e copy of @a bytes. - * @param yybytes the byte buffer to scan - * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. - * - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_bytes(const char *yybytes, yy_size_t _yybytes_len) -{ - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - yy_size_t i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = (yy_size_t)(_yybytes_len + 2); - buf = (char *)yyalloc(n); - if (!buf) - YY_FATAL_ERROR("out of dynamic memory in yy_scan_bytes()"); - - for (i = 0; i < _yybytes_len; ++i) - buf[i] = yybytes[i]; - - buf[_yybytes_len] = buf[_yybytes_len + 1] = YY_END_OF_BUFFER_CHAR; - - b = yy_scan_buffer(buf, n); - if (!b) - YY_FATAL_ERROR("bad buffer in yy_scan_bytes()"); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; -} - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -static void yynoreturn yy_fatal_error(const char *msg) -{ - fprintf(stderr, "%s\n", msg); - exit(YY_EXIT_FAILURE); -} - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - yy_size_t yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg); \ - yytext[yyleng] = (yy_hold_char); \ - (yy_c_buf_p) = yytext + yyless_macro_arg; \ - (yy_hold_char) = *(yy_c_buf_p); \ - *(yy_c_buf_p) = '\0'; \ - yyleng = yyless_macro_arg; \ - } while (0) - -/* Accessor methods (get/set functions) to struct members. */ - -/** Get the current line number. - * - */ -int yyget_lineno(void) { return yylineno; } - -/** Get the input stream. - * - */ -FILE *yyget_in(void) { return yyin; } - -/** Get the output stream. - * - */ -FILE *yyget_out(void) { return yyout; } - -/** Get the length of the current token. - * - */ -yy_size_t yyget_leng(void) { return yyleng; } - -/** Get the current token. - * - */ - -char *yyget_text(void) { return yytext; } - -/** Set the current line number. - * @param _line_number line number - * - */ -void yyset_lineno(int _line_number) { yylineno = _line_number; } - -/** Set the input stream. This does not discard the current - * input buffer. - * @param _in_str A readable stream. - * - * @see yy_switch_to_buffer - */ -void yyset_in(FILE *_in_str) { yyin = _in_str; } - -void yyset_out(FILE *_out_str) { yyout = _out_str; } - -int yyget_debug(void) { return yy_flex_debug; } - -void yyset_debug(int _bdebug) { yy_flex_debug = _bdebug; } - -static int yy_init_globals(void) -{ - /* Initialization is the same as for the non-reentrant scanner. - * This function is called from yylex_destroy(), so don't allocate here. - */ - - (yy_buffer_stack) = NULL; - (yy_buffer_stack_top) = 0; - (yy_buffer_stack_max) = 0; - (yy_c_buf_p) = NULL; - (yy_init) = 0; - (yy_start) = 0; - -/* Defined in main.c */ -#ifdef YY_STDINIT - yyin = stdin; - yyout = stdout; -#else - yyin = NULL; - yyout = NULL; -#endif - - /* For future reference: Set errno on error, since we are called by - * yylex_init() - */ - return 0; -} - -/* yylex_destroy is for both reentrant and non-reentrant scanners. */ -int yylex_destroy(void) -{ - - /* Pop the buffer stack, destroying each element. */ - while (YY_CURRENT_BUFFER) - { - yy_delete_buffer(YY_CURRENT_BUFFER); - YY_CURRENT_BUFFER_LVALUE = NULL; - yypop_buffer_state(); - } - - /* Destroy the stack itself. */ - yyfree((yy_buffer_stack)); - (yy_buffer_stack) = NULL; - - /* Reset the globals. This is important in a non-reentrant scanner so the next time - * yylex() is called, initialization will occur. */ - yy_init_globals(); - - return 0; -} - -/* - * Internal utility routines. - */ - -#ifndef yytext_ptr -static void yy_flex_strncpy(char *s1, const char *s2, int n) -{ - - int i; - for (i = 0; i < n; ++i) - s1[i] = s2[i]; -} -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen(const char *s) -{ - int n; - for (n = 0; s[n]; ++n) - ; - - return n; -} -#endif - -void *yyalloc(yy_size_t size) { return malloc(size); } - -void *yyrealloc(void *ptr, yy_size_t size) -{ - - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return realloc(ptr, size); -} - -void yyfree(void *ptr) { free((char *)ptr); /* see yyrealloc() for (char *) cast */ } - -#define YYTABLES_NAME "yytables" - -#line 47 "lexer.l" diff --git a/source/adios2/toolkit/derived/parser/lexer.l b/source/adios2/toolkit/derived/parser/lexer.l index f81a98bcf9..566e4a41c7 100644 --- a/source/adios2/toolkit/derived/parser/lexer.l +++ b/source/adios2/toolkit/derived/parser/lexer.l @@ -1,47 +1,155 @@ -%{ -#include "parser.hpp" -#define YY_USER_ACTION yylloc.first_line = yylloc.last_line = yylineno; +%{ +#include +#include +#include +#include // strerror +#include +#include "ASTDriver.h" +#include "parser.h" +#if defined(_MSC_VER) +#include +#define YY_NO_UNISTD_H +#define strdup _strdup +#define isatty _isatty +#define fileno _fileno +#include +#include +#endif %} -%option noyywrap +%{ +#if defined __clang__ +# define CLANG_VERSION (__clang_major__ * 100 + __clang_minor__) +#endif +// Clang and ICC like to pretend they are GCC. +#if defined __GNUC__ && !defined __clang__ && !defined __ICC +# define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__) +#endif -DIGIT [0-9] -CHAR ([a-z]|[A-Z]) - -%% +// Pacify warnings in yy_init_buffer (observed with Flex 2.6.4) +// and GCC 6.4.0, 7.3.0 with -O3. +#if defined GCC_VERSION && 600 <= GCC_VERSION +# pragma GCC diagnostic ignored "-Wnull-dereference" +#endif + +// This example uses Flex's C back end, yet compiles it as C++. +// So expect warnings about C style casts and NULL. +#if defined CLANG_VERSION && 500 <= CLANG_VERSION +# pragma clang diagnostic ignored "-Wold-style-cast" +# pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" +#elif defined GCC_VERSION && 407 <= GCC_VERSION +# pragma GCC diagnostic ignored "-Wold-style-cast" +# pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" +#endif + +#define FLEX_VERSION (YY_FLEX_MAJOR_VERSION * 100 + YY_FLEX_MINOR_VERSION) -"+" {yylval.sval=strdup(yytext); return OPERATOR;} -"-" {yylval.sval=strdup(yytext); return OPERATOR;} -"*" {yylval.sval=strdup(yytext); return OPERATOR;} -"/" {yylval.sval=strdup(yytext); return OPERATOR;} -"^" {yylval.sval=strdup(yytext); return OPERATOR;} -"(" {return L_PAREN;} -")" {return R_PAREN;} -"," {return COMMA;} -"add" {yylval.sval=strdup(yytext); return FUNCTION;} -"sqrt" {yylval.sval=strdup(yytext); return FUNCTION;} -"sin" {yylval.sval=strdup(yytext); return FUNCTION;} -"cos" {yylval.sval=strdup(yytext); return FUNCTION;} -"tan" {yylval.sval=strdup(yytext); return FUNCTION;} -"magnitude" {yylval.sval=strdup(yytext); return FUNCTION;} -"curl" {yylval.sval=strdup(yytext); return FUNCTION;} +// Old versions of Flex (2.5.35) generate an incomplete documentation comment. +// +// In file included from src/scan-code-c.c:3: +// src/scan-code.c:2198:21: error: empty paragraph passed to '@param' command +// [-Werror,-Wdocumentation] +// * @param line_number +// ~~~~~~~~~~~~~~~~~^ +// 1 error generated. +#if FLEX_VERSION < 206 && defined CLANG_VERSION +# pragma clang diagnostic ignored "-Wdocumentation" +#endif +// Old versions of Flex (2.5.35) use 'register'. Warnings introduced in +// GCC 7 and Clang 6. +#if FLEX_VERSION < 206 +# if defined CLANG_VERSION && 600 <= CLANG_VERSION +# pragma clang diagnostic ignored "-Wdeprecated-register" +# elif defined GCC_VERSION && 700 <= GCC_VERSION +# pragma GCC diagnostic ignored "-Wregister" +# endif +#endif -(\.{DIGIT}+)|({DIGIT}+(\.{DIGIT}*)?([eE][+-]?[0-9]+)?) {yylval.dval = atof(yytext); return NUMBER;} +#if FLEX_VERSION < 206 +# if defined CLANG_VERSION +# pragma clang diagnostic ignored "-Wconversion" +# pragma clang diagnostic ignored "-Wdocumentation" +# pragma clang diagnostic ignored "-Wshorten-64-to-32" +# pragma clang diagnostic ignored "-Wsign-conversion" +# elif defined GCC_VERSION +# pragma GCC diagnostic ignored "-Wconversion" +# pragma GCC diagnostic ignored "-Wsign-conversion" +# endif +#endif + +// Flex 2.6.4, GCC 9 +// warning: useless cast to type 'int' [-Wuseless-cast] +// 1361 | YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); +// | ^ +#if defined GCC_VERSION && 900 <= GCC_VERSION +# pragma GCC diagnostic ignored "-Wuseless-cast" +#endif +%} -[ \t]+ {/* ignore spaces */} +%option noyywrap nounput noinput batch -(\n|\0|EOF|$end) {return ENDL;} +%{ + // A number symbol corresponding to the value in S. + adios2::detail::parser::symbol_type + make_INT (const std::string &s, const adios2::detail::parser::location_type& loc); +%} -({CHAR}|{DIGIT}|_)+ {yylval.sval=strdup(yytext); return ALIAS;} +op [-+*/^] +id [a-zA-Z][a-zA-Z_0-9_]* +path [a-zA-Z][a-zA-Z0-9_\\./-]* +int [0-9]+ +blank [ \t\r] -:(\\|\/|_|{DIGIT})*{CHAR}+(\\|\/|-|_|{DIGIT}|{CHAR})* {yylval.sval=strndup(yytext + 1,strlen(yytext)-1); return PATH;} +%{ + // Code run each time a pattern is matched. + # define YY_USER_ACTION loc.columns (yyleng); +%} +%% +%{ + // A handy shortcut to the location held by the adios2::detail::ASTDriver. + adios2::detail::location& loc = drv.location; + // Code run each time yylex is called. + loc.step (); +%} +{blank}+ loc.step (); +\n+ loc.lines (yyleng); loc.step (); -'(\\|\/|_|{DIGIT})*{CHAR}+(\\|\/|-|_|{DIGIT}|{CHAR})*' {yylval.sval=strndup(yytext + 1,strlen(yytext)-2); return PATH;} +"=" return adios2::detail::parser::make_ASSIGN (loc); +"," return adios2::detail::parser::make_COMMA (loc); +":" return adios2::detail::parser::make_COLON (loc); +"(" return adios2::detail::parser::make_L_PAREN (loc); +")" return adios2::detail::parser::make_R_PAREN (loc); +"[" return adios2::detail::parser::make_L_BRACE (loc); +"]" return adios2::detail::parser::make_R_BRACE (loc); -"["({DIGIT}+|{DIGIT}*":"{DIGIT}*":"{DIGIT}*)(,({DIGIT}+|{DIGIT}*":"{DIGIT}*":"{DIGIT}*))*"]" {yylval.sval=strndup(yytext + 1,strlen(yytext)-2); return INDICES;} +{int} return make_INT (yytext, loc); +{op} return adios2::detail::parser::make_OPERATOR (yytext, loc); +{id} return adios2::detail::parser::make_IDENTIFIER (yytext, loc); +{path} return adios2::detail::parser::make_VARNAME (yytext, loc); +. { + throw adios2::detail::parser::syntax_error + (loc, "invalid character: " + std::string(yytext)); +} +<> return adios2::detail::parser::make_YYEOF (loc); +%% -. {printf("Error at line %d: unrecognized symbol \"%s\"\n", yylloc.first_line, yytext); exit(0);} +adios2::detail::parser::symbol_type +make_INT (const std::string &s, const adios2::detail::parser::location_type& loc) +{ + errno = 0; + long n = strtol (s.c_str(), NULL, 10); + if (! (INT_MIN <= n && n <= INT_MAX && errno != ERANGE)) + throw adios2::detail::parser::syntax_error (loc, "integer is out of range: " + s); + return adios2::detail::parser::make_INT ((int) n, loc); +} -%% \ No newline at end of file +void +adios2::detail::ASTDriver::parse (const std::string input) +{ + adios2::detail::parser parse (*this); + yy_scan_string(input.c_str()); + parse.set_debug_level (trace_parsing); + parse (); +} diff --git a/source/adios2/toolkit/derived/parser/parser.cpp b/source/adios2/toolkit/derived/parser/parser.cpp deleted file mode 100644 index 03938fc8d6..0000000000 --- a/source/adios2/toolkit/derived/parser/parser.cpp +++ /dev/null @@ -1,1666 +0,0 @@ -/* A Bison parser, made by GNU Bison 2.3. */ - -/* Skeleton implementation for Bison's Yacc-like parsers in C - - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - -/* C LALR(1) parser skeleton written by Richard Stallman, by - simplifying the original so-called "semantic" parser. */ - -/* All symbols defined below should begin with yy or YY, to avoid - infringing on user name space. This should be done even for local - variables, as they might otherwise be expanded by user macros. - There are some unavoidable exceptions within include files to - define necessary library symbols; they are noted "INFRINGES ON - USER NAME SPACE" below. */ - -/* Identify Bison output. */ -#define YYBISON 1 - -/* Bison version. */ -#define YYBISON_VERSION "2.3" - -/* Skeleton name. */ -#define YYSKELETON_NAME "yacc.c" - -/* Pure parsers. */ -#define YYPURE 0 - -/* Using locations. */ -#define YYLSP_NEEDED 1 - -/* Tokens. */ -#ifndef YYTOKENTYPE -#define YYTOKENTYPE -/* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ -enum yytokentype -{ - COMMA = 258, - L_PAREN = 259, - R_PAREN = 260, - ENDL = 261, - FUNCTION = 262, - OPERATOR = 263, - INDICES = 264, - NUMBER = 265, - ALIAS = 266, - PATH = 267 -}; -#endif -/* Tokens. */ -#define COMMA 258 -#define L_PAREN 259 -#define R_PAREN 260 -#define ENDL 261 -#define FUNCTION 262 -#define OPERATOR 263 -#define INDICES 264 -#define NUMBER 265 -#define ALIAS 266 -#define PATH 267 - -/* Copy the first part of user declarations. */ -#line 2 "parser.y" - -#include "parser.h" -#include "lexer.h" -#include -#include -#include -#include -#include -#include - -extern int yyparse(std::stack *expr_stack); - -static void *yyparse_value; - -void yyerror(std::stack *expr_stack, const char *msg); - -namespace adios2 -{ -namespace detail -{ -void *createExpr(std::stack *, std::string, const char *, double, size_t); -} -} - -/* Enabling traces. */ -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif - -/* Enabling verbose error messages. */ -#ifdef YYERROR_VERBOSE -#undef YYERROR_VERBOSE -#define YYERROR_VERBOSE 1 -#else -#define YYERROR_VERBOSE 1 -#endif - -/* Enabling the token table. */ -#ifndef YYTOKEN_TABLE -#define YYTOKEN_TABLE 0 -#endif - -#if !defined YYSTYPE && !defined YYSTYPE_IS_DECLARED -typedef union YYSTYPE -#line 25 "parser.y" -{ - double dval; - int ival; - char *sval; - void *expr_ptr; -} -/* Line 193 of yacc.c. */ -#line 148 "parser.cpp" -YYSTYPE; -#define yystype YYSTYPE /* obsolescent; will be withdrawn */ -#define YYSTYPE_IS_DECLARED 1 -#define YYSTYPE_IS_TRIVIAL 1 -#endif - -#if !defined YYLTYPE && !defined YYLTYPE_IS_DECLARED -typedef struct YYLTYPE -{ - int first_line; - int first_column; - int last_line; - int last_column; -} YYLTYPE; -#define yyltype YYLTYPE /* obsolescent; will be withdrawn */ -#define YYLTYPE_IS_DECLARED 1 -#define YYLTYPE_IS_TRIVIAL 1 -#endif - -/* Copy the second part of user declarations. */ - -/* Line 216 of yacc.c. */ -#line 173 "parser.cpp" - -#ifdef short -#undef short -#endif - -#ifdef YYTYPE_UINT8 -typedef YYTYPE_UINT8 yytype_uint8; -#else -typedef unsigned char yytype_uint8; -#endif - -#ifdef YYTYPE_INT8 -typedef YYTYPE_INT8 yytype_int8; -#elif (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) -typedef signed char yytype_int8; -#else -typedef short int yytype_int8; -#endif - -#ifdef YYTYPE_UINT16 -typedef YYTYPE_UINT16 yytype_uint16; -#else -typedef unsigned short int yytype_uint16; -#endif - -#ifdef YYTYPE_INT16 -typedef YYTYPE_INT16 yytype_int16; -#else -typedef short int yytype_int16; -#endif - -#ifndef YYSIZE_T -#ifdef __SIZE_TYPE__ -#define YYSIZE_T __SIZE_TYPE__ -#elif defined size_t -#define YYSIZE_T size_t -#elif !defined YYSIZE_T && \ - (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) -#include /* INFRINGES ON USER NAME SPACE */ -#define YYSIZE_T size_t -#else -#define YYSIZE_T unsigned int -#endif -#endif - -#define YYSIZE_MAXIMUM ((YYSIZE_T)-1) - -#ifndef YY_ -#if defined YYENABLE_NLS && YYENABLE_NLS -#if ENABLE_NLS -#include /* INFRINGES ON USER NAME SPACE */ -#define YY_(msgid) dgettext("bison-runtime", msgid) -#endif -#endif -#ifndef YY_ -#define YY_(msgid) msgid -#endif -#endif - -/* Suppress unused-variable warnings by "using" E. */ -#if !defined lint || defined __GNUC__ -#define YYUSE(e) ((void)(e)) -#else -#define YYUSE(e) /* empty */ -#endif - -/* Identity function, used to suppress warnings about constant conditions. */ -#ifndef lint -#define YYID(n) (n) -#else -#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) -static int YYID(int i) -#else -static int YYID(i) -int i; -#endif -{ - return i; -} -#endif - -#if !defined yyoverflow || YYERROR_VERBOSE - -/* The parser invokes alloca or malloc; define the necessary symbols. */ - -#ifdef YYSTACK_USE_ALLOCA -#if YYSTACK_USE_ALLOCA -#ifdef __GNUC__ -#define YYSTACK_ALLOC __builtin_alloca -#elif defined __BUILTIN_VA_ARG_INCR -#include /* INFRINGES ON USER NAME SPACE */ -#elif defined _AIX -#define YYSTACK_ALLOC __alloca -#elif defined _MSC_VER -#include /* INFRINGES ON USER NAME SPACE */ -#define alloca _alloca -#else -#define YYSTACK_ALLOC alloca -#if !defined _ALLOCA_H && !defined _STDLIB_H && \ - (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) -#include /* INFRINGES ON USER NAME SPACE */ -#ifndef _STDLIB_H -#define _STDLIB_H 1 -#endif -#endif -#endif -#endif -#endif - -#ifdef YYSTACK_ALLOC -/* Pacify GCC's `empty if-body' warning. */ -#define YYSTACK_FREE(Ptr) \ - do \ - { /* empty */ \ - ; \ - } while (YYID(0)) -#ifndef YYSTACK_ALLOC_MAXIMUM -/* The OS might guarantee only one guard page at the bottom of the stack, - and a page size can be as small as 4096 bytes. So we cannot safely - invoke alloca (N) if N exceeds 4096. Use a slightly smaller number - to allow for a few compiler-allocated temporary stack slots. */ -#define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ -#endif -#else -#define YYSTACK_ALLOC YYMALLOC -#define YYSTACK_FREE YYFREE -#ifndef YYSTACK_ALLOC_MAXIMUM -#define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM -#endif -#if (defined __cplusplus && !defined _STDLIB_H && \ - !((defined YYMALLOC || defined malloc) && (defined YYFREE || defined free))) -#include /* INFRINGES ON USER NAME SPACE */ -#ifndef _STDLIB_H -#define _STDLIB_H 1 -#endif -#endif -#ifndef YYMALLOC -#define YYMALLOC malloc -#if !defined malloc && !defined _STDLIB_H && \ - (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) -void *malloc(YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ -#endif -#endif -#ifndef YYFREE -#define YYFREE free -#if !defined free && !defined _STDLIB_H && \ - (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) -void free(void *); /* INFRINGES ON USER NAME SPACE */ -#endif -#endif -#endif -#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ - -#if (!defined yyoverflow && \ - (!defined __cplusplus || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL && \ - defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) - -/* A type that is properly aligned for any stack member. */ -union yyalloc -{ - yytype_int16 yyss; - YYSTYPE yyvs; - YYLTYPE yyls; -}; - -/* The size of the maximum gap between one aligned stack and the next. */ -#define YYSTACK_GAP_MAXIMUM (sizeof(union yyalloc) - 1) - -/* The size of an array large to enough to hold all stacks, each with - N elements. */ -#define YYSTACK_BYTES(N) \ - ((N) * (sizeof(yytype_int16) + sizeof(YYSTYPE) + sizeof(YYLTYPE)) + 2 * YYSTACK_GAP_MAXIMUM) - -/* Copy COUNT objects from FROM to TO. The source and destination do - not overlap. */ -#ifndef YYCOPY -#if defined __GNUC__ && 1 < __GNUC__ -#define YYCOPY(To, From, Count) __builtin_memcpy(To, From, (Count) * sizeof(*(From))) -#else -#define YYCOPY(To, From, Count) \ - do \ - { \ - YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (To)[yyi] = (From)[yyi]; \ - } while (YYID(0)) -#endif -#endif - -/* Relocate STACK from its old location to the new one. The - local variables YYSIZE and YYSTACKSIZE give the old and new number of - elements in the stack, and YYPTR gives the new location of the - stack. Advance YYPTR to a properly aligned location for the next - stack. */ -#define YYSTACK_RELOCATE(Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY(&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ - yynewbytes = yystacksize * sizeof(*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof(*yyptr); \ - } while (YYID(0)) - -#endif - -/* YYFINAL -- State number of the termination state. */ -#define YYFINAL 16 -/* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 37 - -/* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 13 -/* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 5 -/* YYNRULES -- Number of rules. */ -#define YYNRULES 16 -/* YYNRULES -- Number of states. */ -#define YYNSTATES 28 - -/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ -#define YYUNDEFTOK 2 -#define YYMAXUTOK 267 - -#define YYTRANSLATE(YYX) ((unsigned int)(YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) - -/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ -static const yytype_uint8 yytranslate[] = { - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; - -#if YYDEBUG -/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in - YYRHS. */ -static const yytype_uint8 yyprhs[] = {0, 0, 3, 4, 7, 10, 13, 16, 20, - 24, 26, 28, 31, 33, 35, 39, 43}; - -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const yytype_int8 yyrhs[] = {14, 0, -1, -1, 6, 14, -1, 15, 14, -1, 17, 14, -1, 11, 12, -1, - 11, 12, 9, -1, 16, 3, 17, -1, 17, -1, 11, -1, 11, 9, -1, 12, - -1, 10, -1, 4, 17, 5, -1, 17, 8, 17, -1, 7, 4, 16, 5, -1}; - -/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const yytype_uint8 yyrline[] = {0, 51, 51, 52, 53, 54, 57, 58, 65, - 66, 69, 70, 71, 72, 73, 74, 75}; -#endif - -#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE -/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at YYNTOKENS, nonterminals. */ -static const char *const yytname[] = {"$end", "error", "$undefined", "COMMA", "L_PAREN", - "R_PAREN", "ENDL", "FUNCTION", "OPERATOR", "INDICES", - "NUMBER", "ALIAS", "PATH", "$accept", "input", - "decl", "list", "exp", 0}; -#endif - -#ifdef YYPRINT -/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to - token YYLEX-NUM. */ -static const yytype_uint16 yytoknum[] = {0, 256, 257, 258, 259, 260, 261, - 262, 263, 264, 265, 266, 267}; -#endif - -/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const yytype_uint8 yyr1[] = {0, 13, 14, 14, 14, 14, 15, 15, 16, - 16, 17, 17, 17, 17, 17, 17, 17}; - -/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const yytype_uint8 yyr2[] = {0, 2, 0, 2, 2, 2, 2, 3, 3, 1, 1, 2, 1, 1, 3, 3, 4}; - -/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state - STATE-NUM when YYTABLE doesn't specify something else to do. Zero - means the default is an error. */ -static const yytype_uint8 yydefact[] = {2, 0, 2, 0, 13, 10, 12, 0, 2, 2, 10, 0, 3, 0, - 11, 6, 1, 4, 0, 5, 14, 0, 9, 7, 15, 0, 16, 8}; - -/* YYDEFGOTO[NTERM-NUM]. */ -static const yytype_int8 yydefgoto[] = {-1, 7, 8, 21, 9}; - -/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ -#define YYPACT_NINF -4 -static const yytype_int8 yypact[] = {9, 18, 9, -2, -4, 2, -4, 6, 9, -3, 1, 26, -4, 18, - -4, 14, -4, -4, 18, -4, -4, 32, 10, -4, 10, 18, -4, 10}; - -/* YYPGOTO[NTERM-NUM]. */ -static const yytype_int8 yypgoto[] = {-4, 24, -4, -4, -1}; - -/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule which - number is the opposite. If zero, do what YYDEFACT says. - If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -1 -static const yytype_uint8 yytable[] = {11, 1, 13, 2, 3, 18, 16, 4, 5, 6, 14, 14, 22, - 1, 15, 2, 3, 24, 18, 4, 5, 6, 1, 23, 27, 3, - 12, 0, 4, 10, 6, 20, 17, 19, 18, 25, 0, 26}; - -static const yytype_int8 yycheck[] = {1, 4, 4, 6, 7, 8, 0, 10, 11, 12, 9, 9, 13, - 4, 12, 6, 7, 18, 8, 10, 11, 12, 4, 9, 25, 7, - 2, -1, 10, 11, 12, 5, 8, 9, 8, 3, -1, 5}; - -/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ -static const yytype_uint8 yystos[] = {0, 4, 6, 7, 10, 11, 12, 14, 15, 17, 11, 17, 14, 4, - 9, 12, 0, 14, 8, 14, 5, 16, 17, 9, 17, 3, 5, 17}; - -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 - -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab - -/* Like YYERROR except do call yyerror. This remains here temporarily - to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. */ - -#define YYFAIL goto yyerrlab - -#define YYRECOVERING() (!!yyerrstatus) - -#define YYBACKUP(Token, Value) \ - do \ - if (yychar == YYEMPTY && yylen == 1) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - yytoken = YYTRANSLATE(yychar); \ - YYPOPSTACK(1); \ - goto yybackup; \ - } \ - else \ - { \ - yyerror(expr_stack, YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ - while (YYID(0)) - -#define YYTERROR 1 -#define YYERRCODE 256 - -/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. - If N is 0, then set CURRENT to the empty location which ends - the previous symbol: RHS[0] (always defined). */ - -#define YYRHSLOC(Rhs, K) ((Rhs)[K]) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(Current, Rhs, N) \ - do \ - if (YYID(N)) \ - { \ - (Current).first_line = YYRHSLOC(Rhs, 1).first_line; \ - (Current).first_column = YYRHSLOC(Rhs, 1).first_column; \ - (Current).last_line = YYRHSLOC(Rhs, N).last_line; \ - (Current).last_column = YYRHSLOC(Rhs, N).last_column; \ - } \ - else \ - { \ - (Current).first_line = (Current).last_line = YYRHSLOC(Rhs, 0).last_line; \ - (Current).first_column = (Current).last_column = YYRHSLOC(Rhs, 0).last_column; \ - } \ - while (YYID(0)) -#endif - -/* YY_LOCATION_PRINT -- Print the location on the stream. - This macro was not mandated originally: define only if we know - we won't break user code: when these are the locations we know. */ - -#ifndef YY_LOCATION_PRINT -#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL -#define YY_LOCATION_PRINT(File, Loc) \ - fprintf(File, "%d.%d-%d.%d", (Loc).first_line, (Loc).first_column, (Loc).last_line, \ - (Loc).last_column) -#else -#define YY_LOCATION_PRINT(File, Loc) ((void)0) -#endif -#endif - -/* YYLEX -- calling `yylex' with the right arguments. */ - -#ifdef YYLEX_PARAM -#define YYLEX yylex(YYLEX_PARAM) -#else -#define YYLEX yylex() -#endif - -/* Enable debugging if requested. */ -#if YYDEBUG - -#ifndef YYFPRINTF -#include /* INFRINGES ON USER NAME SPACE */ -#define YYFPRINTF fprintf -#endif - -#define YYDPRINTF(Args) \ - do \ - { \ - if (yydebug) \ - YYFPRINTF Args; \ - } while (YYID(0)) - -#define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ - do \ - { \ - if (yydebug) \ - { \ - YYFPRINTF(stderr, "%s ", Title); \ - yy_symbol_print(stderr, Type, Value, Location, expr_stack); \ - YYFPRINTF(stderr, "\n"); \ - } \ - } while (YYID(0)) - -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ - -/*ARGSUSED*/ -#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) -static void yy_symbol_value_print(FILE *yyoutput, int yytype, YYSTYPE const *const yyvaluep, - YYLTYPE const *const yylocationp, - std::stack *expr_stack) -#else -static void yy_symbol_value_print(yyoutput, yytype, yyvaluep, yylocationp, - expr_stack) FILE *yyoutput; -int yytype; -YYSTYPE const *const yyvaluep; -YYLTYPE const *const yylocationp; -std::stack *expr_stack; -#endif -{ - if (!yyvaluep) - return; - YYUSE(yylocationp); - YYUSE(expr_stack); -#ifdef YYPRINT - if (yytype < YYNTOKENS) - YYPRINT(yyoutput, yytoknum[yytype], *yyvaluep); -#else - YYUSE(yyoutput); -#endif - switch (yytype) - { - default: - break; - } -} - -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ - -#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) -static void yy_symbol_print(FILE *yyoutput, int yytype, YYSTYPE const *const yyvaluep, - YYLTYPE const *const yylocationp, - std::stack *expr_stack) -#else -static void yy_symbol_print(yyoutput, yytype, yyvaluep, yylocationp, expr_stack) FILE *yyoutput; -int yytype; -YYSTYPE const *const yyvaluep; -YYLTYPE const *const yylocationp; -std::stack *expr_stack; -#endif -{ - if (yytype < YYNTOKENS) - YYFPRINTF(yyoutput, "token %s (", yytname[yytype]); - else - YYFPRINTF(yyoutput, "nterm %s (", yytname[yytype]); - - YY_LOCATION_PRINT(yyoutput, *yylocationp); - YYFPRINTF(yyoutput, ": "); - yy_symbol_value_print(yyoutput, yytype, yyvaluep, yylocationp, expr_stack); - YYFPRINTF(yyoutput, ")"); -} - -/*------------------------------------------------------------------. -| yy_stack_print -- Print the state stack from its BOTTOM up to its | -| TOP (included). | -`------------------------------------------------------------------*/ - -#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) -static void yy_stack_print(yytype_int16 *bottom, yytype_int16 *top) -#else -static void yy_stack_print(bottom, top) yytype_int16 *bottom; -yytype_int16 *top; -#endif -{ - YYFPRINTF(stderr, "Stack now"); - for (; bottom <= top; ++bottom) - YYFPRINTF(stderr, " %d", *bottom); - YYFPRINTF(stderr, "\n"); -} - -#define YY_STACK_PRINT(Bottom, Top) \ - do \ - { \ - if (yydebug) \ - yy_stack_print((Bottom), (Top)); \ - } while (YYID(0)) - -/*------------------------------------------------. -| Report that the YYRULE is going to be reduced. | -`------------------------------------------------*/ - -#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) -static void yy_reduce_print(YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, - std::stack *expr_stack) -#else -static void yy_reduce_print(yyvsp, yylsp, yyrule, expr_stack) YYSTYPE *yyvsp; -YYLTYPE *yylsp; -int yyrule; -std::stack *expr_stack; -#endif -{ - int yynrhs = yyr2[yyrule]; - int yyi; - unsigned long int yylno = yyrline[yyrule]; - YYFPRINTF(stderr, "Reducing stack by rule %d (line %lu):\n", yyrule - 1, yylno); - /* The symbols being reduced. */ - for (yyi = 0; yyi < yynrhs; yyi++) - { - fprintf(stderr, " $%d = ", yyi + 1); - yy_symbol_print(stderr, yyrhs[yyprhs[yyrule] + yyi], &(yyvsp[(yyi + 1) - (yynrhs)]), - &(yylsp[(yyi + 1) - (yynrhs)]), expr_stack); - fprintf(stderr, "\n"); - } -} - -#define YY_REDUCE_PRINT(Rule) \ - do \ - { \ - if (yydebug) \ - yy_reduce_print(yyvsp, yylsp, Rule, expr_stack); \ - } while (YYID(0)) - -/* Nonzero means print parse trace. It is left uninitialized so that - multiple parsers can coexist. */ -int yydebug; -#else /* !YYDEBUG */ -#define YYDPRINTF(Args) -#define YY_SYMBOL_PRINT(Title, Type, Value, Location) -#define YY_STACK_PRINT(Bottom, Top) -#define YY_REDUCE_PRINT(Rule) -#endif /* !YYDEBUG */ - -/* YYINITDEPTH -- initial size of the parser's stacks. */ -#ifndef YYINITDEPTH -#define YYINITDEPTH 200 -#endif - -/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only - if the built-in stack extension method is used). - - Do not make this value too large; the results are undefined if - YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) - evaluated with infinite-precision integer arithmetic. */ - -#ifndef YYMAXDEPTH -#define YYMAXDEPTH 10000 -#endif - -#if YYERROR_VERBOSE - -#ifndef yystrlen -#if defined __GLIBC__ && defined _STRING_H -#define yystrlen strlen -#else -/* Return the length of YYSTR. */ -#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) -static YYSIZE_T yystrlen(const char *yystr) -#else -static YYSIZE_T yystrlen(yystr) const char *yystr; -#endif -{ - YYSIZE_T yylen; - for (yylen = 0; yystr[yylen]; yylen++) - continue; - return yylen; -} -#endif -#endif - -#ifndef yystpcpy -#if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE -#define yystpcpy stpcpy -#else -/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in - YYDEST. */ -#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) -static char *yystpcpy(char *yydest, const char *yysrc) -#else -static char *yystpcpy(yydest, yysrc) -char *yydest; -const char *yysrc; -#endif -{ - char *yyd = yydest; - const char *yys = yysrc; - - while ((*yyd++ = *yys++) != '\0') - continue; - - return yyd - 1; -} -#endif -#endif - -#ifndef yytnamerr -/* Copy to YYRES the contents of YYSTR after stripping away unnecessary - quotes and backslashes, so that it's suitable for yyerror. The - heuristic is that double-quoting is unnecessary unless the string - contains an apostrophe, a comma, or backslash (other than - backslash-backslash). YYSTR is taken from yytname. If YYRES is - null, do not copy; instead, return the length of what the result - would have been. */ -static YYSIZE_T yytnamerr(char *yyres, const char *yystr) -{ - if (*yystr == '"') - { - YYSIZE_T yyn = 0; - char const *yyp = yystr; - - for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; - - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - /* Fall through. */ - default: - if (yyres) - yyres[yyn] = *yyp; - yyn++; - break; - - case '"': - if (yyres) - yyres[yyn] = '\0'; - return yyn; - } - do_not_strip_quotes:; - } - - if (!yyres) - return yystrlen(yystr); - - return yystpcpy(yyres, yystr) - yyres; -} -#endif - -/* Copy into YYRESULT an error message about the unexpected token - YYCHAR while in state YYSTATE. Return the number of bytes copied, - including the terminating null byte. If YYRESULT is null, do not - copy anything; just return the number of bytes that would be - copied. As a special case, return 0 if an ordinary "syntax error" - message will do. Return YYSIZE_MAXIMUM if overflow occurs during - size calculation. */ -static YYSIZE_T yysyntax_error(char *yyresult, int yystate, int yychar) -{ - int yyn = yypact[yystate]; - - if (!(YYPACT_NINF < yyn && yyn <= YYLAST)) - return 0; - else - { - int yytype = YYTRANSLATE(yychar); - YYSIZE_T yysize0 = yytnamerr(0, yytname[yytype]); - YYSIZE_T yysize = yysize0; - YYSIZE_T yysize1; - int yysize_overflow = 0; - enum - { - YYERROR_VERBOSE_ARGS_MAXIMUM = 5 - }; - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - int yyx; - -#if 0 - /* This is so xgettext sees the translatable formats that are - constructed on the fly. */ - YY_("syntax error, unexpected %s"); - YY_("syntax error, unexpected %s, expecting %s"); - YY_("syntax error, unexpected %s, expecting %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); -#endif - char *yyfmt; - char const *yyf; - static char const yyunexpected[] = "syntax error, unexpected %s"; - static char const yyexpecting[] = ", expecting %s"; - static char const yyor[] = " or %s"; - char yyformat[sizeof yyunexpected + sizeof yyexpecting - 1 + - ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) * (sizeof yyor - 1))]; - char const *yyprefix = yyexpecting; - - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn + 1; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yycount = 1; - - yyarg[0] = yytname[yytype]; - yyfmt = yystpcpy(yyformat, yyunexpected); - - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - yyformat[sizeof yyunexpected - 1] = '\0'; - break; - } - yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yytnamerr(0, yytname[yyx]); - yysize_overflow |= (yysize1 < yysize); - yysize = yysize1; - yyfmt = yystpcpy(yyfmt, yyprefix); - yyprefix = yyor; - } - - yyf = YY_(yyformat); - yysize1 = yysize + yystrlen(yyf); - yysize_overflow |= (yysize1 < yysize); - yysize = yysize1; - - if (yysize_overflow) - return YYSIZE_MAXIMUM; - - if (yyresult) - { - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - char *yyp = yyresult; - int yyi = 0; - while ((*yyp = *yyf) != '\0') - { - if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) - { - yyp += yytnamerr(yyp, yyarg[yyi++]); - yyf += 2; - } - else - { - yyp++; - yyf++; - } - } - } - return yysize; - } -} -#endif /* YYERROR_VERBOSE */ - -/*-----------------------------------------------. -| Release the memory associated to this symbol. | -`-----------------------------------------------*/ - -/*ARGSUSED*/ -#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) -static void yydestruct(const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, - std::stack *expr_stack) -#else -static void yydestruct(yymsg, yytype, yyvaluep, yylocationp, expr_stack) const char *yymsg; -int yytype; -YYSTYPE *yyvaluep; -YYLTYPE *yylocationp; -std::stack *expr_stack; -#endif -{ - YYUSE(yyvaluep); - YYUSE(yylocationp); - YYUSE(expr_stack); - - if (!yymsg) - yymsg = "Deleting"; - YY_SYMBOL_PRINT(yymsg, yytype, yyvaluep, yylocationp); - - switch (yytype) - { - - default: - break; - } -} - -/* Prevent warnings from -Wmissing-prototypes. */ - -#ifdef YYPARSE_PARAM -#if defined __STDC__ || defined __cplusplus -int yyparse(void *YYPARSE_PARAM); -#else -int yyparse(); -#endif -#else /* ! YYPARSE_PARAM */ -#if defined __STDC__ || defined __cplusplus -int yyparse(std::stack *expr_stack); -#else -int yyparse(); -#endif -#endif /* ! YYPARSE_PARAM */ - -/* The look-ahead symbol. */ -int yychar; - -/* The semantic value of the look-ahead symbol. */ -YYSTYPE yylval; - -/* Number of syntax errors so far. */ -int yynerrs; -/* Location data for the look-ahead symbol. */ -YYLTYPE yylloc; - -/*----------. -| yyparse. | -`----------*/ - -#ifdef YYPARSE_PARAM -#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) -int yyparse(void *YYPARSE_PARAM) -#else -int yyparse(YYPARSE_PARAM) void *YYPARSE_PARAM; -#endif -#else /* ! YYPARSE_PARAM */ -#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) -int yyparse(std::stack *expr_stack) -#else -int yyparse(expr_stack) std::stack *expr_stack; -#endif -#endif -{ - - int yystate; - int yyn; - int yyresult; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - /* Look-ahead token as an internal (translated) token number. */ - int yytoken = 0; -#if YYERROR_VERBOSE - /* Buffer for error messages, and its allocated size. */ - char yymsgbuf[128]; - char *yymsg = yymsgbuf; - YYSIZE_T yymsg_alloc = sizeof yymsgbuf; -#endif - - /* Three stacks and their tools: - `yyss': related to states, - `yyvs': related to semantic values, - `yyls': related to locations. - - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss = yyssa; - yytype_int16 *yyssp; - - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - YYSTYPE *yyvsp; - - /* The location stack. */ - YYLTYPE yylsa[YYINITDEPTH]; - YYLTYPE *yyls = yylsa; - YYLTYPE *yylsp; - /* The locations where the error started and ended. */ - YYLTYPE yyerror_range[2]; - -#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) - - YYSIZE_T yystacksize = YYINITDEPTH; - - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; - YYLTYPE yyloc; - - /* The number of symbols on the RHS of the reduced rule. - Keep to zero when no symbol should be popped. */ - int yylen = 0; - - YYDPRINTF((stderr, "Starting parse\n")); - - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ - - /* Initialize stack pointers. - Waste one element of value and location stack - so that they stay on the same level as the state stack. - The wasted elements are never initialized. */ - - yyssp = yyss; - yyvsp = yyvs; - yylsp = yyls; -#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL - /* Initialize the default location before parsing starts. */ - yylloc.first_line = yylloc.last_line = 1; - yylloc.first_column = yylloc.last_column = 0; -#endif - - goto yysetstate; - - /*------------------------------------------------------------. - | yynewstate -- Push a new state, which is found in yystate. | - `------------------------------------------------------------*/ -yynewstate: - /* In all cases, when you get here, the value and location stacks - have just been pushed. So pushing a state here evens the stacks. */ - yyssp++; - -yysetstate: - *yyssp = yystate; - - if (yyss + yystacksize - 1 <= yyssp) - { - /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; - -#ifdef yyoverflow - { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - YYSTYPE *yyvs1 = yyvs; - yytype_int16 *yyss1 = yyss; - YYLTYPE *yyls1 = yyls; - - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. This used to be a - conditional around just the two extra args, but that might - be undefined if yyoverflow is a macro. */ - yyoverflow(YY_("memory exhausted"), &yyss1, yysize * sizeof(*yyssp), &yyvs1, - yysize * sizeof(*yyvsp), &yyls1, yysize * sizeof(*yylsp), &yystacksize); - yyls = yyls1; - yyss = yyss1; - yyvs = yyvs1; - } -#else /* no yyoverflow */ -#ifndef YYSTACK_RELOCATE - goto yyexhaustedlab; -#else - /* Extend the stack our own way. */ - if (YYMAXDEPTH <= yystacksize) - goto yyexhaustedlab; - yystacksize *= 2; - if (YYMAXDEPTH < yystacksize) - yystacksize = YYMAXDEPTH; - - { - yytype_int16 *yyss1 = yyss; - union yyalloc *yyptr = (union yyalloc *)YYSTACK_ALLOC(YYSTACK_BYTES(yystacksize)); - if (!yyptr) - goto yyexhaustedlab; - YYSTACK_RELOCATE(yyss); - YYSTACK_RELOCATE(yyvs); - YYSTACK_RELOCATE(yyls); -#undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE(yyss1); - } -#endif -#endif /* no yyoverflow */ - - yyssp = yyss + yysize - 1; - yyvsp = yyvs + yysize - 1; - yylsp = yyls + yysize - 1; - - YYDPRINTF((stderr, "Stack size increased to %lu\n", (unsigned long int)yystacksize)); - - if (yyss + yystacksize - 1 <= yyssp) - YYABORT; - } - - YYDPRINTF((stderr, "Entering state %d\n", yystate)); - - goto yybackup; - -/*-----------. -| yybackup. | -`-----------*/ -yybackup: - - /* Do appropriate processing given the current state. Read a - look-ahead token if we need one and don't already have one. */ - - /* First try to decide what to do without reference to look-ahead token. */ - yyn = yypact[yystate]; - if (yyn == YYPACT_NINF) - goto yydefault; - - /* Not known => get a look-ahead token if don't already have one. */ - - /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ - if (yychar == YYEMPTY) - { - YYDPRINTF((stderr, "Reading a token: ")); - yychar = YYLEX; - } - - if (yychar <= YYEOF) - { - yychar = yytoken = YYEOF; - YYDPRINTF((stderr, "Now at end of input.\n")); - } - else - { - yytoken = YYTRANSLATE(yychar); - YY_SYMBOL_PRINT("Next token is", yytoken, &yylval, &yylloc); - } - - /* If the proper action on seeing token YYTOKEN is to reduce or to - detect an error, take that action. */ - yyn += yytoken; - if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) - goto yydefault; - yyn = yytable[yyn]; - if (yyn <= 0) - { - if (yyn == 0 || yyn == YYTABLE_NINF) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } - - if (yyn == YYFINAL) - YYACCEPT; - - /* Count tokens shifted since error; after three, turn off error - status. */ - if (yyerrstatus) - yyerrstatus--; - - /* Shift the look-ahead token. */ - YY_SYMBOL_PRINT("Shifting", yytoken, &yylval, &yylloc); - - /* Discard the shifted token unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; - - yystate = yyn; - *++yyvsp = yylval; - *++yylsp = yylloc; - goto yynewstate; - -/*-----------------------------------------------------------. -| yydefault -- do the default action for the current state. | -`-----------------------------------------------------------*/ -yydefault: - yyn = yydefact[yystate]; - if (yyn == 0) - goto yyerrlab; - goto yyreduce; - -/*-----------------------------. -| yyreduce -- Do a reduction. | -`-----------------------------*/ -yyreduce: - /* yyn is the number of a rule to reduce with. */ - yylen = yyr2[yyn]; - - /* If YYLEN is nonzero, implement the default value of the action: - `$$ = $1'. - - Otherwise, the following line sets YYVAL to garbage. - This behavior is undocumented and Bison - users should not rely upon it. Assigning to YYVAL - unconditionally makes the parser a bit smaller, and it avoids a - GCC warning that YYVAL may be used uninitialized. */ - yyval = yyvsp[1 - yylen]; - - /* Default location. */ - YYLLOC_DEFAULT(yyloc, (yylsp - yylen), yylen); - YY_REDUCE_PRINT(yyn); - switch (yyn) - { - case 2: -#line 51 "parser.y" - { - ; - } - break; - - case 3: -#line 52 "parser.y" - { - ; - } - break; - - case 4: -#line 53 "parser.y" - { - ; - } - break; - - case 5: -#line 54 "parser.y" - { /*yyparse_value = $1->expression;*/ - ; - } - break; - - case 6: -#line 57 "parser.y" - { - adios2::detail::ASTNode::add_lookup_entry((yyvsp[(1) - (2)].sval), (yyvsp[(2) - (2)].sval), - ""); - ; - } - break; - - case 7: -#line 58 "parser.y" - { - adios2::detail::ASTNode::add_lookup_entry((yyvsp[(1) - (3)].sval), (yyvsp[(2) - (3)].sval), - (yyvsp[(3) - (3)].sval)); - ; - } - break; - - case 8: -#line 65 "parser.y" - { - (yyval.ival) = (yyvsp[(1) - (3)].ival) + 1; - ; - } - break; - - case 9: -#line 66 "parser.y" - { - (yyval.ival) = 1; - ; - } - break; - - case 10: -#line 69 "parser.y" - { - (yyval.expr_ptr) = createExpr(expr_stack, "ALIAS", (yyvsp[(1) - (1)].sval), 0, 0); - ; - } - break; - - case 11: -#line 70 "parser.y" - { - createExpr(expr_stack, "ALIAS", (yyvsp[(1) - (2)].sval), 0, 0); - (yyval.expr_ptr) = createExpr(expr_stack, "INDEX", (yyvsp[(2) - (2)].sval), 0, 1); - ; - } - break; - - case 12: -#line 71 "parser.y" - { - (yyval.expr_ptr) = createExpr(expr_stack, "PATH", (yyvsp[(1) - (1)].sval), 0, 0); - ; - } - break; - - case 13: -#line 72 "parser.y" - { - (yyval.expr_ptr) = createExpr(expr_stack, "NUM", "", (yyvsp[(1) - (1)].dval), 0); - ; - } - break; - - case 14: -#line 73 "parser.y" - { - (yyval.expr_ptr) = (yyvsp[(2) - (3)].expr_ptr); - ; - } - break; - - case 15: -#line 74 "parser.y" - { - (yyval.expr_ptr) = createExpr(expr_stack, (yyvsp[(2) - (3)].sval), "", 0, 2); - ; - } - break; - - case 16: -#line 75 "parser.y" - { - (yyval.expr_ptr) = - createExpr(expr_stack, (yyvsp[(1) - (4)].sval), "", 0, (yyvsp[(3) - (4)].ival)); - ; - } - break; - -/* Line 1267 of yacc.c. */ -#line 1480 "parser.cpp" - default: - break; - } - YY_SYMBOL_PRINT("-> $$ =", yyr1[yyn], &yyval, &yyloc); - - YYPOPSTACK(yylen); - yylen = 0; - YY_STACK_PRINT(yyss, yyssp); - - *++yyvsp = yyval; - *++yylsp = yyloc; - - /* Now `shift' the result of the reduction. Determine what state - that goes to, based on the state we popped back to and the rule - number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; - if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTOKENS]; - - goto yynewstate; - -/*------------------------------------. -| yyerrlab -- here on detecting error | -`------------------------------------*/ -yyerrlab: - /* If not already recovering from an error, report this error. */ - if (!yyerrstatus) - { - ++yynerrs; -#if !YYERROR_VERBOSE - yyerror(expr_stack, YY_("syntax error")); -#else - { - YYSIZE_T yysize = yysyntax_error(0, yystate, yychar); - if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) - { - YYSIZE_T yyalloc = 2 * yysize; - if (!(yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) - yyalloc = YYSTACK_ALLOC_MAXIMUM; - if (yymsg != yymsgbuf) - YYSTACK_FREE(yymsg); - yymsg = (char *)YYSTACK_ALLOC(yyalloc); - if (yymsg) - yymsg_alloc = yyalloc; - else - { - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - } - } - - if (0 < yysize && yysize <= yymsg_alloc) - { - (void)yysyntax_error(yymsg, yystate, yychar); - yyerror(expr_stack, yymsg); - } - else - { - yyerror(expr_stack, YY_("syntax error")); - if (yysize != 0) - goto yyexhaustedlab; - } - } -#endif - } - - yyerror_range[0] = yylloc; - - if (yyerrstatus == 3) - { - /* If just tried and failed to reuse look-ahead token after an - error, discard it. */ - - if (yychar <= YYEOF) - { - /* Return failure if at end of input. */ - if (yychar == YYEOF) - YYABORT; - } - else - { - yydestruct("Error: discarding", yytoken, &yylval, &yylloc, expr_stack); - yychar = YYEMPTY; - } - } - - /* Else will try to reuse look-ahead token after shifting the error - token. */ - goto yyerrlab1; - -/*---------------------------------------------------. -| yyerrorlab -- error raised explicitly by YYERROR. | -`---------------------------------------------------*/ -yyerrorlab: - - /* Pacify compilers like GCC when the user code never invokes - YYERROR and the label yyerrorlab therefore never appears in user - code. */ - if (/*CONSTCOND*/ 0) - goto yyerrorlab; - - yyerror_range[0] = yylsp[1 - yylen]; - /* Do not reclaim the symbols of the rule which action triggered - this YYERROR. */ - YYPOPSTACK(yylen); - yylen = 0; - YY_STACK_PRINT(yyss, yyssp); - yystate = *yyssp; - goto yyerrlab1; - -/*-------------------------------------------------------------. -| yyerrlab1 -- common code for both syntax error and YYERROR. | -`-------------------------------------------------------------*/ -yyerrlab1: - yyerrstatus = 3; /* Each real token shifted decrements this. */ - - for (;;) - { - yyn = yypact[yystate]; - if (yyn != YYPACT_NINF) - { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } - } - - /* Pop the current state because it cannot handle the error token. */ - if (yyssp == yyss) - YYABORT; - - yyerror_range[0] = *yylsp; - yydestruct("Error: popping", yystos[yystate], yyvsp, yylsp, expr_stack); - YYPOPSTACK(1); - yystate = *yyssp; - YY_STACK_PRINT(yyss, yyssp); - } - - if (yyn == YYFINAL) - YYACCEPT; - - *++yyvsp = yylval; - - yyerror_range[1] = yylloc; - /* Using YYLLOC is tempting, but would change the location of - the look-ahead. YYLOC is available though. */ - YYLLOC_DEFAULT(yyloc, (yyerror_range - 1), 2); - *++yylsp = yyloc; - - /* Shift the error token. */ - YY_SYMBOL_PRINT("Shifting", yystos[yyn], yyvsp, yylsp); - - yystate = yyn; - goto yynewstate; - -/*-------------------------------------. -| yyacceptlab -- YYACCEPT comes here. | -`-------------------------------------*/ -yyacceptlab: - yyresult = 0; - goto yyreturn; - -/*-----------------------------------. -| yyabortlab -- YYABORT comes here. | -`-----------------------------------*/ -yyabortlab: - yyresult = 1; - goto yyreturn; - -#ifndef yyoverflow -/*-------------------------------------------------. -| yyexhaustedlab -- memory exhaustion comes here. | -`-------------------------------------------------*/ -yyexhaustedlab: - yyerror(expr_stack, YY_("memory exhausted")); - yyresult = 2; - /* Fall through. */ -#endif - -yyreturn: - if (yychar != YYEOF && yychar != YYEMPTY) - yydestruct("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc, expr_stack); - /* Do not reclaim the symbols of the rule which action triggered - this YYABORT or YYACCEPT. */ - YYPOPSTACK(yylen); - YY_STACK_PRINT(yyss, yyssp); - while (yyssp != yyss) - { - yydestruct("Cleanup: popping", yystos[*yyssp], yyvsp, yylsp, expr_stack); - YYPOPSTACK(1); - } -#ifndef yyoverflow - if (yyss != yyssa) - YYSTACK_FREE(yyss); -#endif -#if YYERROR_VERBOSE - if (yymsg != yymsgbuf) - YYSTACK_FREE(yymsg); -#endif - /* Make sure YYID is used. */ - return YYID(yyresult); -} - -#line 77 "parser.y" - -namespace adios2 -{ -namespace detail -{ - -void *createExpr(std::stack *expr_stack, std::string str_op, const char *name, - double value, size_t numsubexprs) -{ - // std::cout << "Creating ASTNode in function createExpr" << std::endl; - // std::cout << "\tstack size: " << expr_stack->size() << "\n\top: " << str_op << "\n\tname: " - // << name << "\n\tvalue: " << value << "\n\tnumsubexprs: " << numsubexprs << std::endl; - - ExpressionOperator op = get_op(str_op); - - ASTNode *node = new ASTNode(op); - switch (op) - { - case ExpressionOperator::OP_ALIAS: - node = new ASTNode(op, name); - break; - case ExpressionOperator::OP_PATH: - node = new ASTNode(op, name); - break; - case ExpressionOperator::OP_NUM: - node = new ASTNode(op, value); - break; - case ExpressionOperator::OP_INDEX: - // TODO: translate indices - node = new ASTNode(op, name); - break; - default: - node = new ASTNode(op); - }; - node->extend_subexprs(numsubexprs); - for (size_t i = 1; i <= numsubexprs; ++i) - { - ASTNode *subexpr = expr_stack->top(); - node->add_back_subexpr(subexpr, i); - expr_stack->pop(); - } - expr_stack->push(node); - - return &expr_stack->top(); -} - -ASTNode *parse_expression(std::string input) -{ - yy_scan_string(input.c_str()); - std::stack expr_stack; - yyparse(&expr_stack); - - // DEBUGGING - // std::cout << "yyparse complete. Stack size: " << expr_stack.size() << std::endl; - // std::cout << "parser prettyprint:" << std::endl; - // expr_stack.top()->printpretty(""); - return expr_stack.top(); -} - -} -} - -void yyerror(std::stack *expr_stack, const char *msg) -{ - printf("** Line %d: %s\n", yylloc.first_line, msg); -} diff --git a/source/adios2/toolkit/derived/parser/parser.h b/source/adios2/toolkit/derived/parser/parser.h deleted file mode 100644 index 38c3c96d58..0000000000 --- a/source/adios2/toolkit/derived/parser/parser.h +++ /dev/null @@ -1,110 +0,0 @@ -/* A Bison parser, made by GNU Bison 2.3. */ - -/* Skeleton interface for Bison's Yacc-like parsers in C - - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - -/* Tokens. */ -#ifndef YYTOKENTYPE -#define YYTOKENTYPE -/* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ -enum yytokentype -{ - COMMA = 258, - L_PAREN = 259, - R_PAREN = 260, - ENDL = 261, - FUNCTION = 262, - OPERATOR = 263, - INDICES = 264, - NUMBER = 265, - ALIAS = 266, - PATH = 267 -}; -#endif -/* Tokens. */ -#define COMMA 258 -#define L_PAREN 259 -#define R_PAREN 260 -#define ENDL 261 -#define FUNCTION 262 -#define OPERATOR 263 -#define INDICES 264 -#define NUMBER 265 -#define ALIAS 266 -#define PATH 267 - -#if !defined YYSTYPE && !defined YYSTYPE_IS_DECLARED -typedef union YYSTYPE -#line 25 "parser.y" -{ - double dval; - int ival; - char *sval; - void *expr_ptr; -} -/* Line 1529 of yacc.c. */ -#line 80 "parser.h" -YYSTYPE; -#define yystype YYSTYPE /* obsolescent; will be withdrawn */ -#define YYSTYPE_IS_DECLARED 1 -#define YYSTYPE_IS_TRIVIAL 1 -#endif - -extern YYSTYPE yylval; - -#if !defined YYLTYPE && !defined YYLTYPE_IS_DECLARED -typedef struct YYLTYPE -{ - int first_line; - int first_column; - int last_line; - int last_column; -} YYLTYPE; -#define yyltype YYLTYPE /* obsolescent; will be withdrawn */ -#define YYLTYPE_IS_DECLARED 1 -#define YYLTYPE_IS_TRIVIAL 1 -#endif - -extern YYLTYPE yylloc; - -#include "ASTNode.h" -#include - -namespace adios2 -{ -namespace detail -{ -ASTNode *parse_expression(std::string input); -} -} diff --git a/source/adios2/toolkit/derived/parser/parser.output b/source/adios2/toolkit/derived/parser/parser.output deleted file mode 100644 index ae7a9b24a1..0000000000 --- a/source/adios2/toolkit/derived/parser/parser.output +++ /dev/null @@ -1,350 +0,0 @@ -State 5 conflicts: 1 shift/reduce -State 24 conflicts: 1 shift/reduce - - -Grammar - - 0 $accept: input $end - - 1 input: /* empty */ - 2 | ENDL input - 3 | decl input - 4 | exp input - - 5 decl: ALIAS PATH - 6 | ALIAS PATH INDICES - - 7 list: list COMMA exp - 8 | exp - - 9 exp: ALIAS - 10 | ALIAS INDICES - 11 | PATH - 12 | NUMBER - 13 | L_PAREN exp R_PAREN - 14 | exp OPERATOR exp - 15 | FUNCTION L_PAREN list R_PAREN - - -Terminals, with rules where they appear - -$end (0) 0 -error (256) -COMMA (258) 7 -L_PAREN (259) 13 15 -R_PAREN (260) 13 15 -ENDL (261) 2 -FUNCTION (262) 15 -OPERATOR (263) 14 -INDICES (264) 6 10 -NUMBER (265) 12 -ALIAS (266) 5 6 9 10 -PATH (267) 5 6 11 - - -Nonterminals, with rules where they appear - -$accept (13) - on left: 0 -input (14) - on left: 1 2 3 4, on right: 0 2 3 4 -decl (15) - on left: 5 6, on right: 3 -list (16) - on left: 7 8, on right: 7 15 -exp (17) - on left: 9 10 11 12 13 14 15, on right: 4 7 8 13 14 - - -state 0 - - 0 $accept: . input $end - - L_PAREN shift, and go to state 1 - ENDL shift, and go to state 2 - FUNCTION shift, and go to state 3 - NUMBER shift, and go to state 4 - ALIAS shift, and go to state 5 - PATH shift, and go to state 6 - - $default reduce using rule 1 (input) - - input go to state 7 - decl go to state 8 - exp go to state 9 - - -state 1 - - 13 exp: L_PAREN . exp R_PAREN - - L_PAREN shift, and go to state 1 - FUNCTION shift, and go to state 3 - NUMBER shift, and go to state 4 - ALIAS shift, and go to state 10 - PATH shift, and go to state 6 - - exp go to state 11 - - -state 2 - - 2 input: ENDL . input - - L_PAREN shift, and go to state 1 - ENDL shift, and go to state 2 - FUNCTION shift, and go to state 3 - NUMBER shift, and go to state 4 - ALIAS shift, and go to state 5 - PATH shift, and go to state 6 - - $default reduce using rule 1 (input) - - input go to state 12 - decl go to state 8 - exp go to state 9 - - -state 3 - - 15 exp: FUNCTION . L_PAREN list R_PAREN - - L_PAREN shift, and go to state 13 - - -state 4 - - 12 exp: NUMBER . - - $default reduce using rule 12 (exp) - - -state 5 - - 5 decl: ALIAS . PATH - 6 | ALIAS . PATH INDICES - 9 exp: ALIAS . - 10 | ALIAS . INDICES - - INDICES shift, and go to state 14 - PATH shift, and go to state 15 - - PATH [reduce using rule 9 (exp)] - $default reduce using rule 9 (exp) - - -state 6 - - 11 exp: PATH . - - $default reduce using rule 11 (exp) - - -state 7 - - 0 $accept: input . $end - - $end shift, and go to state 16 - - -state 8 - - 3 input: decl . input - - L_PAREN shift, and go to state 1 - ENDL shift, and go to state 2 - FUNCTION shift, and go to state 3 - NUMBER shift, and go to state 4 - ALIAS shift, and go to state 5 - PATH shift, and go to state 6 - - $default reduce using rule 1 (input) - - input go to state 17 - decl go to state 8 - exp go to state 9 - - -state 9 - - 4 input: exp . input - 14 exp: exp . OPERATOR exp - - L_PAREN shift, and go to state 1 - ENDL shift, and go to state 2 - FUNCTION shift, and go to state 3 - OPERATOR shift, and go to state 18 - NUMBER shift, and go to state 4 - ALIAS shift, and go to state 5 - PATH shift, and go to state 6 - - $default reduce using rule 1 (input) - - input go to state 19 - decl go to state 8 - exp go to state 9 - - -state 10 - - 9 exp: ALIAS . - 10 | ALIAS . INDICES - - INDICES shift, and go to state 14 - - $default reduce using rule 9 (exp) - - -state 11 - - 13 exp: L_PAREN exp . R_PAREN - 14 | exp . OPERATOR exp - - R_PAREN shift, and go to state 20 - OPERATOR shift, and go to state 18 - - -state 12 - - 2 input: ENDL input . - - $default reduce using rule 2 (input) - - -state 13 - - 15 exp: FUNCTION L_PAREN . list R_PAREN - - L_PAREN shift, and go to state 1 - FUNCTION shift, and go to state 3 - NUMBER shift, and go to state 4 - ALIAS shift, and go to state 10 - PATH shift, and go to state 6 - - list go to state 21 - exp go to state 22 - - -state 14 - - 10 exp: ALIAS INDICES . - - $default reduce using rule 10 (exp) - - -state 15 - - 5 decl: ALIAS PATH . - 6 | ALIAS PATH . INDICES - - INDICES shift, and go to state 23 - - $default reduce using rule 5 (decl) - - -state 16 - - 0 $accept: input $end . - - $default accept - - -state 17 - - 3 input: decl input . - - $default reduce using rule 3 (input) - - -state 18 - - 14 exp: exp OPERATOR . exp - - L_PAREN shift, and go to state 1 - FUNCTION shift, and go to state 3 - NUMBER shift, and go to state 4 - ALIAS shift, and go to state 10 - PATH shift, and go to state 6 - - exp go to state 24 - - -state 19 - - 4 input: exp input . - - $default reduce using rule 4 (input) - - -state 20 - - 13 exp: L_PAREN exp R_PAREN . - - $default reduce using rule 13 (exp) - - -state 21 - - 7 list: list . COMMA exp - 15 exp: FUNCTION L_PAREN list . R_PAREN - - COMMA shift, and go to state 25 - R_PAREN shift, and go to state 26 - - -state 22 - - 8 list: exp . - 14 exp: exp . OPERATOR exp - - OPERATOR shift, and go to state 18 - - $default reduce using rule 8 (list) - - -state 23 - - 6 decl: ALIAS PATH INDICES . - - $default reduce using rule 6 (decl) - - -state 24 - - 14 exp: exp . OPERATOR exp - 14 | exp OPERATOR exp . - - OPERATOR shift, and go to state 18 - - OPERATOR [reduce using rule 14 (exp)] - $default reduce using rule 14 (exp) - - -state 25 - - 7 list: list COMMA . exp - - L_PAREN shift, and go to state 1 - FUNCTION shift, and go to state 3 - NUMBER shift, and go to state 4 - ALIAS shift, and go to state 10 - PATH shift, and go to state 6 - - exp go to state 27 - - -state 26 - - 15 exp: FUNCTION L_PAREN list R_PAREN . - - $default reduce using rule 15 (exp) - - -state 27 - - 7 list: list COMMA exp . - 14 exp: exp . OPERATOR exp - - OPERATOR shift, and go to state 18 - - $default reduce using rule 7 (list) \ No newline at end of file diff --git a/source/adios2/toolkit/derived/parser/parser.y b/source/adios2/toolkit/derived/parser/parser.y index d9bf172459..a258b34bc1 100644 --- a/source/adios2/toolkit/derived/parser/parser.y +++ b/source/adios2/toolkit/derived/parser/parser.y @@ -1,132 +1,113 @@ -/* calculator. */ -%{ - #include - #include - #include - #include - #include - #include - #include - #include "lexer.h" - #include "ASTNode.h" - - extern int yyparse(std::stack* expr_stack); - - void* createExpr(std::stack*, std::string, const char*, double, size_t); - - static void* yyparse_value; - - void yyerror(std::stack* expr_stack, const char *msg); - -%} - -%parse-param {std::stack* expr_stack} - -%union{ - double dval; - int ival; - char* sval; - void* expr_ptr; +%skeleton "lalr1.cc" +%require "3.8.2" +%header + +%define api.token.raw +%define api.namespace {adios2::detail} +%define api.token.constructor +%define api.value.type variant +%define parse.assert + +%code requires { + #include + #include + #include + namespace adios2 + { + namespace detail + { + class ASTDriver; + } + } } -%error-verbose -%locations +// The parsing context. +%param { ASTDriver& drv } -%start input -%token COMMA L_PAREN R_PAREN ENDL -%token FUNCTION -%token OPERATOR -%token INDICES -%token NUMBER -%token ALIAS PATH -%type NUMBER -%type ALIAS PATH INDICES -%type FUNCTION OPERATOR -%type input exp -%type list - - -%% - -input: {} - | ENDL input {} - | decl input {} - | exp input { /*yyparse_value = $1->expression;*/ } - ; - -decl: ALIAS PATH { ASTNode::add_lookup_entry($1, $2, ""); } - | ALIAS PATH INDICES { ASTNode::add_lookup_entry($1, $2, $3); } - ; - -//index: NUMBER comma index { ASTNode::extend_current_lookup_indices($1); } -// | NUMBER { ASTNode::extend_current_lookup_indices($1); } -// ; - -list: list COMMA exp { $$ = $1 +1; } - | exp { $$ = 1;} - ; - -exp: ALIAS { $$ = createExpr(expr_stack, "ALIAS", $1, 0, 0); } -| ALIAS INDICES { createExpr(expr_stack, "ALIAS", $1, 0, 0); $$ = createExpr(expr_stack, "INDEX", $2, 0, 1); } -| PATH { $$ = createExpr(expr_stack, "PATH", $1, 0, 0); } -| NUMBER { $$ = createExpr(expr_stack, "NUM", "", $1, 0); } -| L_PAREN exp R_PAREN { $$ = $2; } -| exp OPERATOR exp { $$ = createExpr(expr_stack, $2, "", 0, 2); } -| FUNCTION L_PAREN list R_PAREN { $$ = createExpr(expr_stack, $1, "", 0, $3); } - ; -%% +%locations -void* createExpr(std::stack* expr_stack, std::string str_op, const char* name, double value, size_t numsubexprs) { - std::cout << "Creating ASTNode in function createExpr" << std::endl; - std::cout << "\tstack size: " << expr_stack->size() << "\n\top: " << str_op << "\n\tname: " << name << "\n\tvalue: " << value << "\n\tnumsubexprs: " << numsubexprs << std::endl; - - ExprHelper::expr_op op = ExprHelper::get_op(str_op); - - ASTNode *node = new ASTNode(op); - switch(op) { - case ExprHelper::OP_ALIAS: - node = new ASTNode(op, name); - break; - case ExprHelper::OP_PATH: - node = new ASTNode(op, name); - break; - case ExprHelper::OP_NUM: - node = new ASTNode(op, value); - break; - case ExprHelper::OP_INDEX: - // TODO: translate indices - node = new ASTNode(op, name); - break; - default: - node = new ASTNode(op); - }; - node->extend_subexprs(numsubexprs); - for (size_t i = 1; i <= numsubexprs; ++i) - { - ASTNode *subexpr = expr_stack->top(); - node->add_back_subexpr(subexpr,i); - expr_stack->pop(); - } - expr_stack->push(node); +%define parse.trace +%define parse.error detailed +%define parse.lac full - return &expr_stack->top(); +%code { +#include "ASTDriver.h" +#include "ASTNode.h" } -Expression* parse_expression(const char* input) { - yy_scan_string(input); - std::stack expr_stack; - yyparse(&expr_stack); +%define api.token.prefix {TOK_} +%token + ASSIGN "=" + COMMA "," + COLON ":" + L_PAREN "(" + R_PAREN ")" + L_BRACE "[" + R_BRACE "]" +; + +%token OPERATOR +%token IDENTIFIER "identifier" +%token VARNAME +%token INT "number" +%nterm list +%nterm >> indices_list +%nterm > index +%left OPERATOR - // DEBUGGING - std::cout << "yyparse complete. Stack size: " << expr_stack.size() << std::endl; - std::cout << "parser prettyprint:" << std::endl; - expr_stack.top()->printpretty(""); +%% +%start lines; +lines: + assignment lines {} +| exp {} +; + +assignment: + IDENTIFIER ASSIGN VARNAME { drv.add_lookup_entry($1, $3); } +| IDENTIFIER ASSIGN IDENTIFIER { drv.add_lookup_entry($1, $3); } +| IDENTIFIER ASSIGN VARNAME L_BRACE indices_list R_BRACE { drv.add_lookup_entry($1, $3, $5); } +| IDENTIFIER ASSIGN IDENTIFIER L_BRACE indices_list R_BRACE { drv.add_lookup_entry($1, $3, $5); } +; + +exp: + "number" { } +| exp OPERATOR exp { drv.createNode($2, 2); } +| "(" exp ")" { } +| IDENTIFIER "(" list ")" { drv.createNode($1, $3); } +| IDENTIFIER "[" indices_list "]" { drv.createNode($1, $3); } +| IDENTIFIER { drv.createNode($1); } +; + + +indices_list: + %empty { $$ = {}; } +| indices_list COMMA index { $1.push_back($3); $$ = $1; } +| index { $$ = {$1}; } +; + +index: + %empty { $$ = {-1, -1, 1}; } +| INT COLON INT COLON INT { $$ = {$1, $3, $5}; } +| COLON INT COLON INT { $$ = {-1, $2, $4}; } +| INT COLON COLON INT { $$ = {$1, -1, $4}; } +| INT COLON INT COLON { $$ = {$1, $3, 1}; } +| INT COLON INT { $$ = {$1, $3, 1}; } +| COLON COLON INT { $$ = {-1, -1, $3}; } +| COLON INT COLON { $$ = {-1, $2, 1}; } +| COLON INT { $$ = {-1, $2, 1}; } +| INT COLON COLON { $$ = {$1, -1, 1}; } +| INT COLON { $$ = {$1, -1, 1}; } +| INT { $$ = {$1, $1, 1}; } +; + +list: + %empty { $$ = 0; } +| exp COMMA list { $$ = $3 + 1; } +| exp { $$ = 1; } +%% - Expression *dummy_root = new Expression(); - expr_stack.top()->to_expr(dummy_root); - return std::get<0>(dummy_root->sub_exprs[0]); +void +adios2::detail::parser::error (const location_type& l, const std::string& m) +{ + std::cerr << l << ": " << m << '\n'; } - -void yyerror(std::stack* expr_stack, const char *msg) { - printf("** Line %d: %s\n", yylloc.first_line, msg); -} \ No newline at end of file diff --git a/source/adios2/toolkit/derived/parser/pregen-source/lexer.cpp b/source/adios2/toolkit/derived/parser/pregen-source/lexer.cpp new file mode 100644 index 0000000000..11c2e6b66a --- /dev/null +++ b/source/adios2/toolkit/derived/parser/pregen-source/lexer.cpp @@ -0,0 +1,1906 @@ +#line 1 "lexer.cpp" + +#line 3 "lexer.cpp" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 6 +#define YY_FLEX_SUBMINOR_VERSION 4 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + +#endif /* ! C99 */ + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ + +/* TODO: this is always defined, so inline it */ +#define yyconst const + +#if defined(__GNUC__) && __GNUC__ >= 3 +#define yynoreturn __attribute__((__noreturn__)) +#else +#define yynoreturn +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. + */ +#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN (yy_start) = 1 + 2 * +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START (((yy_start) - 1) / 2) +#define YYSTATE YY_START +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin ) +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else +#define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +extern yy_size_t yyleng; + +extern FILE *yyin, *yyout; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + #define YY_LINENO_REWIND_TO(ptr) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) +#define unput(c) yyunput( c, (yytext_ptr) ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + int yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* Stack of input buffers. */ +static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ +static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ +static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +/* yy_hold_char holds the character lost when yytext is formed. */ +static char yy_hold_char; +static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */ +yy_size_t yyleng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = NULL; +static int yy_init = 0; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void yyrestart ( FILE *input_file ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size ); +void yy_delete_buffer ( YY_BUFFER_STATE b ); +void yy_flush_buffer ( YY_BUFFER_STATE b ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer ); +void yypop_buffer_state ( void ); + +static void yyensure_buffer_stack ( void ); +static void yy_load_buffer_state ( void ); +static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file ); +#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER ) + +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, yy_size_t len ); + +void *yyalloc ( yy_size_t ); +void *yyrealloc ( void *, yy_size_t ); +void yyfree ( void * ); + +#define yy_new_buffer yy_create_buffer +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +#define yywrap() (/*CONSTCOND*/1) +#define YY_SKIP_YYWRAP +typedef flex_uint8_t YY_CHAR; + +FILE *yyin = NULL, *yyout = NULL; + +typedef int yy_state_type; + +extern int yylineno; +int yylineno = 1; + +extern char *yytext; +#ifdef yytext_ptr +#undef yytext_ptr +#endif +#define yytext_ptr yytext + +static yy_state_type yy_get_previous_state ( void ); +static yy_state_type yy_try_NUL_trans ( yy_state_type current_state ); +static int yy_get_next_buffer ( void ); +static void yynoreturn yy_fatal_error ( const char* msg ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ + (yy_c_buf_p) = yy_cp; +#define YY_NUM_RULES 15 +#define YY_END_OF_BUFFER 16 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static const flex_int16_t yy_accept[23] = + { 0, + 0, 0, 16, 14, 1, 2, 6, 7, 11, 4, + 10, 5, 3, 12, 8, 9, 1, 2, 10, 13, + 12, 0 + } ; + +static const YY_CHAR yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 1, 1, 1, 1, 1, 1, 4, + 5, 6, 6, 7, 8, 9, 8, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 11, 1, 1, + 12, 1, 1, 1, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 14, 9, 15, 6, 16, 1, 13, 13, 13, 13, + + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static const YY_CHAR yy_meta[17] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, + 1, 1, 2, 1, 1, 2 + } ; + +static const flex_int16_t yy_base[25] = + { 0, + 0, 0, 29, 30, 26, 24, 30, 30, 30, 30, + 16, 30, 30, 9, 30, 30, 23, 21, 13, 0, + 11, 30, 20, 19 + } ; + +static const flex_int16_t yy_def[25] = + { 0, + 22, 1, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 23, 22, 22, 22, 22, 22, 24, + 23, 0, 22, 22 + } ; + +static const flex_int16_t yy_nxt[47] = + { 0, + 4, 5, 6, 7, 8, 9, 10, 9, 4, 11, + 12, 13, 14, 15, 16, 4, 20, 20, 20, 20, + 20, 21, 19, 18, 17, 19, 18, 17, 22, 3, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22 + } ; + +static const flex_int16_t yy_chk[47] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 14, 14, 21, 21, + 24, 23, 19, 18, 17, 11, 6, 5, 3, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22 + } ; + +static yy_state_type yy_last_accepting_state; +static char *yy_last_accepting_cpos; + +extern int yy_flex_debug; +int yy_flex_debug = 0; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +char *yytext; +#line 1 "../lexer.l" +#line 2 "../lexer.l" +#include +#include +#include +#include // strerror +#include +#include "ASTDriver.h" +#include "parser.h" +#if defined(_MSC_VER) +#include +#define YY_NO_UNISTD_H +#define strdup _strdup +#define isatty _isatty +#define fileno _fileno +#include +#include +#endif +#line 477 "lexer.cpp" +#line 21 "../lexer.l" +#if defined __clang__ +# define CLANG_VERSION (__clang_major__ * 100 + __clang_minor__) +#endif + +// Clang and ICC like to pretend they are GCC. +#if defined __GNUC__ && !defined __clang__ && !defined __ICC +# define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__) +#endif + +// Pacify warnings in yy_init_buffer (observed with Flex 2.6.4) +// and GCC 6.4.0, 7.3.0 with -O3. +#if defined GCC_VERSION && 600 <= GCC_VERSION +# pragma GCC diagnostic ignored "-Wnull-dereference" +#endif + +// This example uses Flex's C back end, yet compiles it as C++. +// So expect warnings about C style casts and NULL. +#if defined CLANG_VERSION && 500 <= CLANG_VERSION +# pragma clang diagnostic ignored "-Wold-style-cast" +# pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" +#elif defined GCC_VERSION && 407 <= GCC_VERSION +# pragma GCC diagnostic ignored "-Wold-style-cast" +# pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" +#endif + +#define FLEX_VERSION (YY_FLEX_MAJOR_VERSION * 100 + YY_FLEX_MINOR_VERSION) + +// Old versions of Flex (2.5.35) generate an incomplete documentation comment. +// +// In file included from src/scan-code-c.c:3: +// src/scan-code.c:2198:21: error: empty paragraph passed to '@param' command +// [-Werror,-Wdocumentation] +// * @param line_number +// ~~~~~~~~~~~~~~~~~^ +// 1 error generated. +#if FLEX_VERSION < 206 && defined CLANG_VERSION +# pragma clang diagnostic ignored "-Wdocumentation" +#endif + +// Old versions of Flex (2.5.35) use 'register'. Warnings introduced in +// GCC 7 and Clang 6. +#if FLEX_VERSION < 206 +# if defined CLANG_VERSION && 600 <= CLANG_VERSION +# pragma clang diagnostic ignored "-Wdeprecated-register" +# elif defined GCC_VERSION && 700 <= GCC_VERSION +# pragma GCC diagnostic ignored "-Wregister" +# endif +#endif + +#if FLEX_VERSION < 206 +# if defined CLANG_VERSION +# pragma clang diagnostic ignored "-Wconversion" +# pragma clang diagnostic ignored "-Wdocumentation" +# pragma clang diagnostic ignored "-Wshorten-64-to-32" +# pragma clang diagnostic ignored "-Wsign-conversion" +# elif defined GCC_VERSION +# pragma GCC diagnostic ignored "-Wconversion" +# pragma GCC diagnostic ignored "-Wsign-conversion" +# endif +#endif + +// Flex 2.6.4, GCC 9 +// warning: useless cast to type 'int' [-Wuseless-cast] +// 1361 | YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); +// | ^ +#if defined GCC_VERSION && 900 <= GCC_VERSION +# pragma GCC diagnostic ignored "-Wuseless-cast" +#endif +#line 547 "lexer.cpp" +#define YY_NO_INPUT 1 +#line 94 "../lexer.l" + // A number symbol corresponding to the value in S. + adios2::detail::parser::symbol_type + make_INT (const std::string &s, const adios2::detail::parser::location_type& loc); +#line 553 "lexer.cpp" +#line 106 "../lexer.l" + // Code run each time a pattern is matched. + # define YY_USER_ACTION loc.columns (yyleng); +#line 557 "lexer.cpp" +#line 558 "lexer.cpp" + +#define INITIAL 0 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +static int yy_init_globals ( void ); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int yylex_destroy ( void ); + +int yyget_debug ( void ); + +void yyset_debug ( int debug_flag ); + +YY_EXTRA_TYPE yyget_extra ( void ); + +void yyset_extra ( YY_EXTRA_TYPE user_defined ); + +FILE *yyget_in ( void ); + +void yyset_in ( FILE * _in_str ); + +FILE *yyget_out ( void ); + +void yyset_out ( FILE * _out_str ); + + yy_size_t yyget_leng ( void ); + +char *yyget_text ( void ); + +int yyget_lineno ( void ); + +void yyset_lineno ( int _line_number ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap ( void ); +#else +extern int yywrap ( void ); +#endif +#endif + +#ifndef YY_NO_UNPUT + +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy ( char *, const char *, int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen ( const char * ); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput ( void ); +#else +static int input ( void ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else +#define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + yy_size_t n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int yylex (void); + +#define YY_DECL int yylex (void) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK /*LINTED*/break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + yy_state_type yy_current_state; + char *yy_cp, *yy_bp; + int yy_act; + + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_load_buffer_state( ); + } + + { +#line 109 "../lexer.l" + + +#line 112 "../lexer.l" + // A handy shortcut to the location held by the adios2::detail::ASTDriver. + adios2::detail::location& loc = drv.location; + // Code run each time yylex is called. + loc.step (); + +#line 782 "lexer.cpp" + + while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of yytext. */ + *yy_cp = (yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = (yy_start); +yy_match: + do + { + YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 23 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + ++yy_cp; + } + while ( yy_current_state != 22 ); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = (yy_hold_char); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 117 "../lexer.l" +loc.step (); + YY_BREAK +case 2: +/* rule 2 can match eol */ +YY_RULE_SETUP +#line 118 "../lexer.l" +loc.lines (yyleng); loc.step (); + YY_BREAK +case 3: +YY_RULE_SETUP +#line 120 "../lexer.l" +return adios2::detail::parser::make_ASSIGN (loc); + YY_BREAK +case 4: +YY_RULE_SETUP +#line 121 "../lexer.l" +return adios2::detail::parser::make_COMMA (loc); + YY_BREAK +case 5: +YY_RULE_SETUP +#line 122 "../lexer.l" +return adios2::detail::parser::make_COLON (loc); + YY_BREAK +case 6: +YY_RULE_SETUP +#line 123 "../lexer.l" +return adios2::detail::parser::make_L_PAREN (loc); + YY_BREAK +case 7: +YY_RULE_SETUP +#line 124 "../lexer.l" +return adios2::detail::parser::make_R_PAREN (loc); + YY_BREAK +case 8: +YY_RULE_SETUP +#line 125 "../lexer.l" +return adios2::detail::parser::make_L_BRACE (loc); + YY_BREAK +case 9: +YY_RULE_SETUP +#line 126 "../lexer.l" +return adios2::detail::parser::make_R_BRACE (loc); + YY_BREAK +case 10: +YY_RULE_SETUP +#line 128 "../lexer.l" +return make_INT (yytext, loc); + YY_BREAK +case 11: +YY_RULE_SETUP +#line 129 "../lexer.l" +return adios2::detail::parser::make_OPERATOR (yytext, loc); + YY_BREAK +case 12: +YY_RULE_SETUP +#line 130 "../lexer.l" +return adios2::detail::parser::make_IDENTIFIER (yytext, loc); + YY_BREAK +case 13: +YY_RULE_SETUP +#line 131 "../lexer.l" +return adios2::detail::parser::make_VARNAME (yytext, loc); + YY_BREAK +case 14: +YY_RULE_SETUP +#line 132 "../lexer.l" +{ + throw adios2::detail::parser::syntax_error + (loc, "invalid character: " + std::string(yytext)); +} + YY_BREAK +case YY_STATE_EOF(INITIAL): +#line 136 "../lexer.l" +return adios2::detail::parser::make_YYEOF (loc); + YY_BREAK +case 15: +YY_RULE_SETUP +#line 137 "../lexer.l" +ECHO; + YY_BREAK +#line 918 "lexer.cpp" + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = (yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_END_OF_FILE: + { + (yy_did_buffer_switch_on_eof) = 0; + + if ( yywrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ + } /* end of user's declarations */ +} /* end of yylex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (void) +{ + char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + char *source = (yytext_ptr); + int number_to_move, i; + int ret_val; + + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr) - 1); + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + + int yy_c_buf_p_offset = + (int) ((yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + yy_size_t new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = NULL; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + if ( (yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( + (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + /* "- 2" to take care of EOB's */ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); + } + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (void) +{ + yy_state_type yy_current_state; + char *yy_cp; + + yy_current_state = (yy_start); + + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + { + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 23 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) +{ + int yy_is_jam; + char *yy_cp = (yy_c_buf_p); + + YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 23 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + yy_is_jam = (yy_current_state == 22); + + return yy_is_jam ? 0 : yy_current_state; +} + +#ifndef YY_NO_UNPUT + +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (void) +#else + static int input (void) +#endif + +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); + + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + /* This was really a NUL. */ + *(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); + ++(yy_c_buf_p); + + switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( ) ) + return 0; + + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = (yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve yytext */ + (yy_hold_char) = *++(yy_c_buf_p); + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyrestart (FILE * input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file ); + yy_load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + +static void yy_load_buffer_state (void) +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * + */ + void yy_delete_buffer (YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yyfree( (void *) b->yy_ch_buf ); + + yyfree( (void *) b ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file ) + +{ + int oerrno = errno; + + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void yy_flush_buffer (YY_BUFFER_STATE b ) +{ + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) +{ + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void yypop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void yyensure_buffer_stack (void) +{ + yy_size_t num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ + (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + yy_size_t grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return NULL; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = NULL; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer( b ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to yylex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * yy_scan_bytes() instead. + */ +YY_BUFFER_STATE yy_scan_string (const char * yystr ) +{ + + return yy_scan_bytes( yystr, (int) strlen(yystr) ); +} + +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will + * scan from a @e copy of @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, yy_size_t _yybytes_len ) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + yy_size_t i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyalloc( n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n ); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yynoreturn yy_fatal_error (const char* msg ) +{ + fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + yy_size_t yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = yytext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the current line number. + * + */ +int yyget_lineno (void) +{ + + return yylineno; +} + +/** Get the input stream. + * + */ +FILE *yyget_in (void) +{ + return yyin; +} + +/** Get the output stream. + * + */ +FILE *yyget_out (void) +{ + return yyout; +} + +/** Get the length of the current token. + * + */ +yy_size_t yyget_leng (void) +{ + return yyleng; +} + +/** Get the current token. + * + */ + +char *yyget_text (void) +{ + return yytext; +} + +/** Set the current line number. + * @param _line_number line number + * + */ +void yyset_lineno (int _line_number ) +{ + + yylineno = _line_number; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param _in_str A readable stream. + * + * @see yy_switch_to_buffer + */ +void yyset_in (FILE * _in_str ) +{ + yyin = _in_str ; +} + +void yyset_out (FILE * _out_str ) +{ + yyout = _out_str ; +} + +int yyget_debug (void) +{ + return yy_flex_debug; +} + +void yyset_debug (int _bdebug ) +{ + yy_flex_debug = _bdebug ; +} + +static int yy_init_globals (void) +{ + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from yylex_destroy(), so don't allocate here. + */ + + (yy_buffer_stack) = NULL; + (yy_buffer_stack_top) = 0; + (yy_buffer_stack_max) = 0; + (yy_c_buf_p) = NULL; + (yy_init) = 0; + (yy_start) = 0; + +/* Defined in main.c */ +#ifdef YY_STDINIT + yyin = stdin; + yyout = stdout; +#else + yyin = NULL; + yyout = NULL; +#endif + + /* For future reference: Set errno on error, since we are called by + * yylex_init() + */ + return 0; +} + +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (void) +{ + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + yy_delete_buffer( YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + yypop_buffer_state(); + } + + /* Destroy the stack itself. */ + yyfree((yy_buffer_stack) ); + (yy_buffer_stack) = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * yylex() is called, initialization will occur. */ + yy_init_globals( ); + + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, const char * s2, int n ) +{ + + int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (const char * s ) +{ + int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *yyalloc (yy_size_t size ) +{ + return malloc(size); +} + +void *yyrealloc (void * ptr, yy_size_t size ) +{ + + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return realloc(ptr, size); +} + +void yyfree (void * ptr ) +{ + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 137 "../lexer.l" + + +adios2::detail::parser::symbol_type +make_INT (const std::string &s, const adios2::detail::parser::location_type& loc) +{ + errno = 0; + long n = strtol (s.c_str(), NULL, 10); + if (! (INT_MIN <= n && n <= INT_MAX && errno != ERANGE)) + throw adios2::detail::parser::syntax_error (loc, "integer is out of range: " + s); + return adios2::detail::parser::make_INT ((int) n, loc); +} + +void +adios2::detail::ASTDriver::parse (const std::string input) +{ + adios2::detail::parser parse (*this); + yy_scan_string(input.c_str()); + parse.set_debug_level (trace_parsing); + parse (); +} + diff --git a/source/adios2/toolkit/derived/parser/lexer.h b/source/adios2/toolkit/derived/parser/pregen-source/lexer.h similarity index 71% rename from source/adios2/toolkit/derived/parser/lexer.h rename to source/adios2/toolkit/derived/parser/pregen-source/lexer.h index 75c3a14657..c83d2213a8 100644 --- a/source/adios2/toolkit/derived/parser/lexer.h +++ b/source/adios2/toolkit/derived/parser/pregen-source/lexer.h @@ -6,7 +6,7 @@ #line 7 "lexer.h" -#define YY_INT_ALIGNED short int +#define YY_INT_ALIGNED short int /* A lexical scanner generated by flex */ @@ -21,10 +21,10 @@ /* First, we deal with platform-specific or compiler-specific issues. */ /* begin standard C headers. */ -#include #include -#include #include +#include +#include /* end standard C headers. */ @@ -35,10 +35,10 @@ /* C99 systems have . Non-C99 systems may or may not. */ -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. + * if you want the limit (max/min) macros for int types. */ #ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS 1 @@ -56,41 +56,41 @@ typedef uint64_t flex_uint64_t; typedef signed char flex_int8_t; typedef short int flex_int16_t; typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; +typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; /* Limits of integral types. */ #ifndef INT8_MIN -#define INT8_MIN (-128) +#define INT8_MIN (-128) #endif #ifndef INT16_MIN -#define INT16_MIN (-32767 - 1) +#define INT16_MIN (-32767-1) #endif #ifndef INT32_MIN -#define INT32_MIN (-2147483647 - 1) +#define INT32_MIN (-2147483647-1) #endif #ifndef INT8_MAX -#define INT8_MAX (127) +#define INT8_MAX (127) #endif #ifndef INT16_MAX -#define INT16_MAX (32767) +#define INT16_MAX (32767) #endif #ifndef INT32_MAX -#define INT32_MAX (2147483647) +#define INT32_MAX (2147483647) #endif #ifndef UINT8_MAX -#define UINT8_MAX (255U) +#define UINT8_MAX (255U) #endif #ifndef UINT16_MAX -#define UINT16_MAX (65535U) +#define UINT16_MAX (65535U) #endif #ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) +#define UINT32_MAX (4294967295U) #endif #ifndef SIZE_MAX -#define SIZE_MAX (~(size_t)0) +#define SIZE_MAX (~(size_t)0) #endif #endif /* ! C99 */ @@ -138,72 +138,73 @@ extern FILE *yyin, *yyout; #ifndef YY_STRUCT_YY_BUFFER_STATE #define YY_STRUCT_YY_BUFFER_STATE struct yy_buffer_state -{ - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - int yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - yy_size_t yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + int yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; - int yy_buffer_status; -}; + }; #endif /* !YY_STRUCT_YY_BUFFER_STATE */ -void yyrestart(FILE *input_file); -void yy_switch_to_buffer(YY_BUFFER_STATE new_buffer); -YY_BUFFER_STATE yy_create_buffer(FILE *file, int size); -void yy_delete_buffer(YY_BUFFER_STATE b); -void yy_flush_buffer(YY_BUFFER_STATE b); -void yypush_buffer_state(YY_BUFFER_STATE new_buffer); -void yypop_buffer_state(void); +void yyrestart ( FILE *input_file ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size ); +void yy_delete_buffer ( YY_BUFFER_STATE b ); +void yy_flush_buffer ( YY_BUFFER_STATE b ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer ); +void yypop_buffer_state ( void ); -YY_BUFFER_STATE yy_scan_buffer(char *base, yy_size_t size); -YY_BUFFER_STATE yy_scan_string(const char *yy_str); -YY_BUFFER_STATE yy_scan_bytes(const char *bytes, yy_size_t len); +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, yy_size_t len ); -void *yyalloc(yy_size_t); -void *yyrealloc(void *, yy_size_t); -void yyfree(void *); +void *yyalloc ( yy_size_t ); +void *yyrealloc ( void *, yy_size_t ); +void yyfree ( void * ); /* Begin user sect3 */ -#define yywrap() (/*CONSTCOND*/ 1) +#define yywrap() (/*CONSTCOND*/1) #define YY_SKIP_YYWRAP extern int yylineno; @@ -234,31 +235,31 @@ extern char *yytext; /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ -int yylex_destroy(void); +int yylex_destroy ( void ); -int yyget_debug(void); +int yyget_debug ( void ); -void yyset_debug(int debug_flag); +void yyset_debug ( int debug_flag ); -YY_EXTRA_TYPE yyget_extra(void); +YY_EXTRA_TYPE yyget_extra ( void ); -void yyset_extra(YY_EXTRA_TYPE user_defined); +void yyset_extra ( YY_EXTRA_TYPE user_defined ); -FILE *yyget_in(void); +FILE *yyget_in ( void ); -void yyset_in(FILE *_in_str); +void yyset_in ( FILE * _in_str ); -FILE *yyget_out(void); +FILE *yyget_out ( void ); -void yyset_out(FILE *_out_str); +void yyset_out ( FILE * _out_str ); -yy_size_t yyget_leng(void); + yy_size_t yyget_leng ( void ); -char *yyget_text(void); +char *yyget_text ( void ); -int yyget_lineno(void); +int yyget_lineno ( void ); -void yyset_lineno(int _line_number); +void yyset_lineno ( int _line_number ); /* Macros after this point can all be overridden by user definitions in * section 1. @@ -266,18 +267,18 @@ void yyset_lineno(int _line_number); #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus -extern "C" int yywrap(void); +extern "C" int yywrap ( void ); #else -extern int yywrap(void); +extern int yywrap ( void ); #endif #endif #ifndef yytext_ptr -static void yy_flex_strncpy(char *, const char *, int); +static void yy_flex_strncpy ( char *, const char *, int ); #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen(const char *); +static int yy_flex_strlen ( const char * ); #endif #ifndef YY_NO_INPUT @@ -305,9 +306,9 @@ static int yy_flex_strlen(const char *); #ifndef YY_DECL #define YY_DECL_IS_OURS 1 -extern int yylex(void); +extern int yylex (void); -#define YY_DECL int yylex(void) +#define YY_DECL int yylex (void) #endif /* !YY_DECL */ /* yy_get_previous_state - get the state just before the EOB char was reached */ @@ -469,7 +470,8 @@ extern int yylex(void); #undef yyTABLES_NAME #endif -#line 47 "lexer.l" +#line 137 "../lexer.l" + #line 476 "lexer.h" #undef yyIN_HEADER diff --git a/source/adios2/toolkit/derived/parser/pregen-source/location.hh b/source/adios2/toolkit/derived/parser/pregen-source/location.hh new file mode 100644 index 0000000000..923c49c812 --- /dev/null +++ b/source/adios2/toolkit/derived/parser/pregen-source/location.hh @@ -0,0 +1,306 @@ +// A Bison parser, made by GNU Bison 3.8.2. + +// Locations for Bison parsers in C++ + +// Copyright (C) 2002-2015, 2018-2021 Free Software Foundation, Inc. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// As a special exception, you may create a larger work that contains +// part or all of the Bison parser skeleton and distribute that work +// under terms of your choice, so long as that work isn't itself a +// parser generator using the skeleton or a modified version thereof +// as a parser skeleton. Alternatively, if you modify or redistribute +// the parser skeleton itself, you may (at your option) remove this +// special exception, which will cause the skeleton and the resulting +// Bison output files to be licensed under the GNU General Public +// License without this special exception. + +// This special exception was added by the Free Software Foundation in +// version 2.2 of Bison. + +/** + ** \file location.hh + ** Define the adios2::detail::location class. + */ + +#ifndef YY_YY_LOCATION_HH_INCLUDED +# define YY_YY_LOCATION_HH_INCLUDED + +# include +# include + +# ifndef YY_NULLPTR +# if defined __cplusplus +# if 201103L <= __cplusplus +# define YY_NULLPTR nullptr +# else +# define YY_NULLPTR 0 +# endif +# else +# define YY_NULLPTR ((void*)0) +# endif +# endif + +#line 6 "../parser.y" +namespace adios2 { namespace detail { +#line 59 "location.hh" + + /// A point in a source file. + class position + { + public: + /// Type for file name. + typedef const std::string filename_type; + /// Type for line and column numbers. + typedef int counter_type; + + /// Construct a position. + explicit position (filename_type* f = YY_NULLPTR, + counter_type l = 1, + counter_type c = 1) + : filename (f) + , line (l) + , column (c) + {} + + + /// Initialization. + void initialize (filename_type* fn = YY_NULLPTR, + counter_type l = 1, + counter_type c = 1) + { + filename = fn; + line = l; + column = c; + } + + /** \name Line and Column related manipulators + ** \{ */ + /// (line related) Advance to the COUNT next lines. + void lines (counter_type count = 1) + { + if (count) + { + column = 1; + line = add_ (line, count, 1); + } + } + + /// (column related) Advance to the COUNT next columns. + void columns (counter_type count = 1) + { + column = add_ (column, count, 1); + } + /** \} */ + + /// File name to which this position refers. + filename_type* filename; + /// Current line number. + counter_type line; + /// Current column number. + counter_type column; + + private: + /// Compute max (min, lhs+rhs). + static counter_type add_ (counter_type lhs, counter_type rhs, counter_type min) + { + return lhs + rhs < min ? min : lhs + rhs; + } + }; + + /// Add \a width columns, in place. + inline position& + operator+= (position& res, position::counter_type width) + { + res.columns (width); + return res; + } + + /// Add \a width columns. + inline position + operator+ (position res, position::counter_type width) + { + return res += width; + } + + /// Subtract \a width columns, in place. + inline position& + operator-= (position& res, position::counter_type width) + { + return res += -width; + } + + /// Subtract \a width columns. + inline position + operator- (position res, position::counter_type width) + { + return res -= width; + } + + /** \brief Intercept output stream redirection. + ** \param ostr the destination output stream + ** \param pos a reference to the position to redirect + */ + template + std::basic_ostream& + operator<< (std::basic_ostream& ostr, const position& pos) + { + if (pos.filename) + ostr << *pos.filename << ':'; + return ostr << pos.line << '.' << pos.column; + } + + /// Two points in a source file. + class location + { + public: + /// Type for file name. + typedef position::filename_type filename_type; + /// Type for line and column numbers. + typedef position::counter_type counter_type; + + /// Construct a location from \a b to \a e. + location (const position& b, const position& e) + : begin (b) + , end (e) + {} + + /// Construct a 0-width location in \a p. + explicit location (const position& p = position ()) + : begin (p) + , end (p) + {} + + /// Construct a 0-width location in \a f, \a l, \a c. + explicit location (filename_type* f, + counter_type l = 1, + counter_type c = 1) + : begin (f, l, c) + , end (f, l, c) + {} + + + /// Initialization. + void initialize (filename_type* f = YY_NULLPTR, + counter_type l = 1, + counter_type c = 1) + { + begin.initialize (f, l, c); + end = begin; + } + + /** \name Line and Column related manipulators + ** \{ */ + public: + /// Reset initial location to final location. + void step () + { + begin = end; + } + + /// Extend the current location to the COUNT next columns. + void columns (counter_type count = 1) + { + end += count; + } + + /// Extend the current location to the COUNT next lines. + void lines (counter_type count = 1) + { + end.lines (count); + } + /** \} */ + + + public: + /// Beginning of the located region. + position begin; + /// End of the located region. + position end; + }; + + /// Join two locations, in place. + inline location& + operator+= (location& res, const location& end) + { + res.end = end.end; + return res; + } + + /// Join two locations. + inline location + operator+ (location res, const location& end) + { + return res += end; + } + + /// Add \a width columns to the end position, in place. + inline location& + operator+= (location& res, location::counter_type width) + { + res.columns (width); + return res; + } + + /// Add \a width columns to the end position. + inline location + operator+ (location res, location::counter_type width) + { + return res += width; + } + + /// Subtract \a width columns to the end position, in place. + inline location& + operator-= (location& res, location::counter_type width) + { + return res += -width; + } + + /// Subtract \a width columns to the end position. + inline location + operator- (location res, location::counter_type width) + { + return res -= width; + } + + /** \brief Intercept output stream redirection. + ** \param ostr the destination output stream + ** \param loc a reference to the location to redirect + ** + ** Avoid duplicate information. + */ + template + std::basic_ostream& + operator<< (std::basic_ostream& ostr, const location& loc) + { + location::counter_type end_col + = 0 < loc.end.column ? loc.end.column - 1 : 0; + ostr << loc.begin; + if (loc.end.filename + && (!loc.begin.filename + || *loc.begin.filename != *loc.end.filename)) + ostr << '-' << loc.end.filename << ':' << loc.end.line << '.' << end_col; + else if (loc.begin.line < loc.end.line) + ostr << '-' << loc.end.line << '.' << end_col; + else if (loc.begin.column < end_col) + ostr << '-' << end_col; + return ostr; + } + +#line 6 "../parser.y" +} } // adios2::detail +#line 305 "location.hh" + +#endif // !YY_YY_LOCATION_HH_INCLUDED diff --git a/source/adios2/toolkit/derived/parser/pregen-source/parser.cpp b/source/adios2/toolkit/derived/parser/pregen-source/parser.cpp new file mode 100644 index 0000000000..e11401c54d --- /dev/null +++ b/source/adios2/toolkit/derived/parser/pregen-source/parser.cpp @@ -0,0 +1,1414 @@ +// A Bison parser, made by GNU Bison 3.8.2. + +// Skeleton implementation for Bison LALR(1) parsers in C++ + +// Copyright (C) 2002-2015, 2018-2021 Free Software Foundation, Inc. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// As a special exception, you may create a larger work that contains +// part or all of the Bison parser skeleton and distribute that work +// under terms of your choice, so long as that work isn't itself a +// parser generator using the skeleton or a modified version thereof +// as a parser skeleton. Alternatively, if you modify or redistribute +// the parser skeleton itself, you may (at your option) remove this +// special exception, which will cause the skeleton and the resulting +// Bison output files to be licensed under the GNU General Public +// License without this special exception. + +// This special exception was added by the Free Software Foundation in +// version 2.2 of Bison. + +// DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual, +// especially those whose name start with YY_ or yy_. They are +// private implementation details that can be changed or removed. + + + + + +#include "parser.h" + + +// Unqualified %code blocks. +#line 33 "../parser.y" + +#include "ASTDriver.h" +#include "ASTNode.h" + +#line 51 "parser.cpp" + + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include // FIXME: INFRINGES ON USER NAME SPACE. +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + + +// Whether we are compiled with exception support. +#ifndef YY_EXCEPTIONS +# if defined __GNUC__ && !defined __EXCEPTIONS +# define YY_EXCEPTIONS 0 +# else +# define YY_EXCEPTIONS 1 +# endif +#endif + +#define YYRHSLOC(Rhs, K) ((Rhs)[K].location) +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +# ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (N) \ + { \ + (Current).begin = YYRHSLOC (Rhs, 1).begin; \ + (Current).end = YYRHSLOC (Rhs, N).end; \ + } \ + else \ + { \ + (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \ + } \ + while (false) +# endif + + +// Enable debugging if requested. +#if YYDEBUG + +// A pseudo ostream that takes yydebug_ into account. +# define YYCDEBUG if (yydebug_) (*yycdebug_) + +# define YY_SYMBOL_PRINT(Title, Symbol) \ + do { \ + if (yydebug_) \ + { \ + *yycdebug_ << Title << ' '; \ + yy_print_ (*yycdebug_, Symbol); \ + *yycdebug_ << '\n'; \ + } \ + } while (false) + +# define YY_REDUCE_PRINT(Rule) \ + do { \ + if (yydebug_) \ + yy_reduce_print_ (Rule); \ + } while (false) + +# define YY_STACK_PRINT() \ + do { \ + if (yydebug_) \ + yy_stack_print_ (); \ + } while (false) + +#else // !YYDEBUG + +# define YYCDEBUG if (false) std::cerr +# define YY_SYMBOL_PRINT(Title, Symbol) YY_USE (Symbol) +# define YY_REDUCE_PRINT(Rule) static_cast (0) +# define YY_STACK_PRINT() static_cast (0) + +#endif // !YYDEBUG + +#define yyerrok (yyerrstatus_ = 0) +#define yyclearin (yyla.clear ()) + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab +#define YYRECOVERING() (!!yyerrstatus_) + +#line 6 "../parser.y" +namespace adios2 { namespace detail { +#line 144 "parser.cpp" + + /// Build a parser object. + parser::parser (ASTDriver& drv_yyarg) +#if YYDEBUG + : yydebug_ (false), + yycdebug_ (&std::cerr), +#else + : +#endif + yy_lac_established_ (false), + drv (drv_yyarg) + {} + + parser::~parser () + {} + + parser::syntax_error::~syntax_error () YY_NOEXCEPT YY_NOTHROW + {} + + /*---------. + | symbol. | + `---------*/ + + + + // by_state. + parser::by_state::by_state () YY_NOEXCEPT + : state (empty_state) + {} + + parser::by_state::by_state (const by_state& that) YY_NOEXCEPT + : state (that.state) + {} + + void + parser::by_state::clear () YY_NOEXCEPT + { + state = empty_state; + } + + void + parser::by_state::move (by_state& that) + { + state = that.state; + that.clear (); + } + + parser::by_state::by_state (state_type s) YY_NOEXCEPT + : state (s) + {} + + parser::symbol_kind_type + parser::by_state::kind () const YY_NOEXCEPT + { + if (state == empty_state) + return symbol_kind::S_YYEMPTY; + else + return YY_CAST (symbol_kind_type, yystos_[+state]); + } + + parser::stack_symbol_type::stack_symbol_type () + {} + + parser::stack_symbol_type::stack_symbol_type (YY_RVREF (stack_symbol_type) that) + : super_type (YY_MOVE (that.state), YY_MOVE (that.location)) + { + switch (that.kind ()) + { + case symbol_kind::S_INT: // "number" + case symbol_kind::S_list: // list + value.YY_MOVE_OR_COPY< int > (YY_MOVE (that.value)); + break; + + case symbol_kind::S_OPERATOR: // OPERATOR + case symbol_kind::S_IDENTIFIER: // "identifier" + case symbol_kind::S_VARNAME: // VARNAME + value.YY_MOVE_OR_COPY< std::string > (YY_MOVE (that.value)); + break; + + case symbol_kind::S_index: // index + value.YY_MOVE_OR_COPY< std::tuple > (YY_MOVE (that.value)); + break; + + case symbol_kind::S_indices_list: // indices_list + value.YY_MOVE_OR_COPY< std::vector> > (YY_MOVE (that.value)); + break; + + default: + break; + } + +#if 201103L <= YY_CPLUSPLUS + // that is emptied. + that.state = empty_state; +#endif + } + + parser::stack_symbol_type::stack_symbol_type (state_type s, YY_MOVE_REF (symbol_type) that) + : super_type (s, YY_MOVE (that.location)) + { + switch (that.kind ()) + { + case symbol_kind::S_INT: // "number" + case symbol_kind::S_list: // list + value.move< int > (YY_MOVE (that.value)); + break; + + case symbol_kind::S_OPERATOR: // OPERATOR + case symbol_kind::S_IDENTIFIER: // "identifier" + case symbol_kind::S_VARNAME: // VARNAME + value.move< std::string > (YY_MOVE (that.value)); + break; + + case symbol_kind::S_index: // index + value.move< std::tuple > (YY_MOVE (that.value)); + break; + + case symbol_kind::S_indices_list: // indices_list + value.move< std::vector> > (YY_MOVE (that.value)); + break; + + default: + break; + } + + // that is emptied. + that.kind_ = symbol_kind::S_YYEMPTY; + } + +#if YY_CPLUSPLUS < 201103L + parser::stack_symbol_type& + parser::stack_symbol_type::operator= (const stack_symbol_type& that) + { + state = that.state; + switch (that.kind ()) + { + case symbol_kind::S_INT: // "number" + case symbol_kind::S_list: // list + value.copy< int > (that.value); + break; + + case symbol_kind::S_OPERATOR: // OPERATOR + case symbol_kind::S_IDENTIFIER: // "identifier" + case symbol_kind::S_VARNAME: // VARNAME + value.copy< std::string > (that.value); + break; + + case symbol_kind::S_index: // index + value.copy< std::tuple > (that.value); + break; + + case symbol_kind::S_indices_list: // indices_list + value.copy< std::vector> > (that.value); + break; + + default: + break; + } + + location = that.location; + return *this; + } + + parser::stack_symbol_type& + parser::stack_symbol_type::operator= (stack_symbol_type& that) + { + state = that.state; + switch (that.kind ()) + { + case symbol_kind::S_INT: // "number" + case symbol_kind::S_list: // list + value.move< int > (that.value); + break; + + case symbol_kind::S_OPERATOR: // OPERATOR + case symbol_kind::S_IDENTIFIER: // "identifier" + case symbol_kind::S_VARNAME: // VARNAME + value.move< std::string > (that.value); + break; + + case symbol_kind::S_index: // index + value.move< std::tuple > (that.value); + break; + + case symbol_kind::S_indices_list: // indices_list + value.move< std::vector> > (that.value); + break; + + default: + break; + } + + location = that.location; + // that is emptied. + that.state = empty_state; + return *this; + } +#endif + + template + void + parser::yy_destroy_ (const char* yymsg, basic_symbol& yysym) const + { + if (yymsg) + YY_SYMBOL_PRINT (yymsg, yysym); + } + +#if YYDEBUG + template + void + parser::yy_print_ (std::ostream& yyo, const basic_symbol& yysym) const + { + std::ostream& yyoutput = yyo; + YY_USE (yyoutput); + if (yysym.empty ()) + yyo << "empty symbol"; + else + { + symbol_kind_type yykind = yysym.kind (); + yyo << (yykind < YYNTOKENS ? "token" : "nterm") + << ' ' << yysym.name () << " (" + << yysym.location << ": "; + YY_USE (yykind); + yyo << ')'; + } + } +#endif + + void + parser::yypush_ (const char* m, YY_MOVE_REF (stack_symbol_type) sym) + { + if (m) + YY_SYMBOL_PRINT (m, sym); + yystack_.push (YY_MOVE (sym)); + } + + void + parser::yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym) + { +#if 201103L <= YY_CPLUSPLUS + yypush_ (m, stack_symbol_type (s, std::move (sym))); +#else + stack_symbol_type ss (s, sym); + yypush_ (m, ss); +#endif + } + + void + parser::yypop_ (int n) YY_NOEXCEPT + { + yystack_.pop (n); + } + +#if YYDEBUG + std::ostream& + parser::debug_stream () const + { + return *yycdebug_; + } + + void + parser::set_debug_stream (std::ostream& o) + { + yycdebug_ = &o; + } + + + parser::debug_level_type + parser::debug_level () const + { + return yydebug_; + } + + void + parser::set_debug_level (debug_level_type l) + { + yydebug_ = l; + } +#endif // YYDEBUG + + parser::state_type + parser::yy_lr_goto_state_ (state_type yystate, int yysym) + { + int yyr = yypgoto_[yysym - YYNTOKENS] + yystate; + if (0 <= yyr && yyr <= yylast_ && yycheck_[yyr] == yystate) + return yytable_[yyr]; + else + return yydefgoto_[yysym - YYNTOKENS]; + } + + bool + parser::yy_pact_value_is_default_ (int yyvalue) YY_NOEXCEPT + { + return yyvalue == yypact_ninf_; + } + + bool + parser::yy_table_value_is_error_ (int yyvalue) YY_NOEXCEPT + { + return yyvalue == yytable_ninf_; + } + + int + parser::operator() () + { + return parse (); + } + + int + parser::parse () + { + int yyn; + /// Length of the RHS of the rule being reduced. + int yylen = 0; + + // Error handling. + int yynerrs_ = 0; + int yyerrstatus_ = 0; + + /// The lookahead symbol. + symbol_type yyla; + + /// The locations where the error started and ended. + stack_symbol_type yyerror_range[3]; + + /// The return value of parse (). + int yyresult; + + // Discard the LAC context in case there still is one left from a + // previous invocation. + yy_lac_discard_ ("init"); + +#if YY_EXCEPTIONS + try +#endif // YY_EXCEPTIONS + { + YYCDEBUG << "Starting parse\n"; + + + /* Initialize the stack. The initial state will be set in + yynewstate, since the latter expects the semantical and the + location values to have been already stored, initialize these + stacks with a primary value. */ + yystack_.clear (); + yypush_ (YY_NULLPTR, 0, YY_MOVE (yyla)); + + /*-----------------------------------------------. + | yynewstate -- push a new symbol on the stack. | + `-----------------------------------------------*/ + yynewstate: + YYCDEBUG << "Entering state " << int (yystack_[0].state) << '\n'; + YY_STACK_PRINT (); + + // Accept? + if (yystack_[0].state == yyfinal_) + YYACCEPT; + + goto yybackup; + + + /*-----------. + | yybackup. | + `-----------*/ + yybackup: + // Try to take a decision without lookahead. + yyn = yypact_[+yystack_[0].state]; + if (yy_pact_value_is_default_ (yyn)) + goto yydefault; + + // Read a lookahead token. + if (yyla.empty ()) + { + YYCDEBUG << "Reading a token\n"; +#if YY_EXCEPTIONS + try +#endif // YY_EXCEPTIONS + { + symbol_type yylookahead (yylex (drv)); + yyla.move (yylookahead); + } +#if YY_EXCEPTIONS + catch (const syntax_error& yyexc) + { + YYCDEBUG << "Caught exception: " << yyexc.what() << '\n'; + error (yyexc); + goto yyerrlab1; + } +#endif // YY_EXCEPTIONS + } + YY_SYMBOL_PRINT ("Next token is", yyla); + + if (yyla.kind () == symbol_kind::S_YYerror) + { + // The scanner already issued an error message, process directly + // to error recovery. But do not keep the error token as + // lookahead, it is too special and may lead us to an endless + // loop in error recovery. */ + yyla.kind_ = symbol_kind::S_YYUNDEF; + goto yyerrlab1; + } + + /* If the proper action on seeing token YYLA.TYPE is to reduce or + to detect an error, take that action. */ + yyn += yyla.kind (); + if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yyla.kind ()) + { + if (!yy_lac_establish_ (yyla.kind ())) + goto yyerrlab; + goto yydefault; + } + + // Reduce or error. + yyn = yytable_[yyn]; + if (yyn <= 0) + { + if (yy_table_value_is_error_ (yyn)) + goto yyerrlab; + if (!yy_lac_establish_ (yyla.kind ())) + goto yyerrlab; + + yyn = -yyn; + goto yyreduce; + } + + // Count tokens shifted since error; after three, turn off error status. + if (yyerrstatus_) + --yyerrstatus_; + + // Shift the lookahead token. + yypush_ ("Shifting", state_type (yyn), YY_MOVE (yyla)); + yy_lac_discard_ ("shift"); + goto yynewstate; + + + /*-----------------------------------------------------------. + | yydefault -- do the default action for the current state. | + `-----------------------------------------------------------*/ + yydefault: + yyn = yydefact_[+yystack_[0].state]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + + /*-----------------------------. + | yyreduce -- do a reduction. | + `-----------------------------*/ + yyreduce: + yylen = yyr2_[yyn]; + { + stack_symbol_type yylhs; + yylhs.state = yy_lr_goto_state_ (yystack_[yylen].state, yyr1_[yyn]); + /* Variants are always initialized to an empty instance of the + correct type. The default '$$ = $1' action is NOT applied + when using variants. */ + switch (yyr1_[yyn]) + { + case symbol_kind::S_INT: // "number" + case symbol_kind::S_list: // list + yylhs.value.emplace< int > (); + break; + + case symbol_kind::S_OPERATOR: // OPERATOR + case symbol_kind::S_IDENTIFIER: // "identifier" + case symbol_kind::S_VARNAME: // VARNAME + yylhs.value.emplace< std::string > (); + break; + + case symbol_kind::S_index: // index + yylhs.value.emplace< std::tuple > (); + break; + + case symbol_kind::S_indices_list: // indices_list + yylhs.value.emplace< std::vector> > (); + break; + + default: + break; + } + + + // Default location. + { + stack_type::slice range (yystack_, yylen); + YYLLOC_DEFAULT (yylhs.location, range, yylen); + yyerror_range[1].location = yylhs.location; + } + + // Perform the reduction. + YY_REDUCE_PRINT (yyn); +#if YY_EXCEPTIONS + try +#endif // YY_EXCEPTIONS + { + switch (yyn) + { + case 2: // lines: assignment lines +#line 61 "../parser.y" + {} +#line 644 "parser.cpp" + break; + + case 3: // lines: exp +#line 62 "../parser.y" + {} +#line 650 "parser.cpp" + break; + + case 4: // assignment: "identifier" "=" VARNAME +#line 66 "../parser.y" + { drv.add_lookup_entry(yystack_[2].value.as < std::string > (), yystack_[0].value.as < std::string > ()); } +#line 656 "parser.cpp" + break; + + case 5: // assignment: "identifier" "=" "identifier" +#line 67 "../parser.y" + { drv.add_lookup_entry(yystack_[2].value.as < std::string > (), yystack_[0].value.as < std::string > ()); } +#line 662 "parser.cpp" + break; + + case 6: // assignment: "identifier" "=" VARNAME "[" indices_list "]" +#line 68 "../parser.y" + { drv.add_lookup_entry(yystack_[5].value.as < std::string > (), yystack_[3].value.as < std::string > (), yystack_[1].value.as < std::vector> > ()); } +#line 668 "parser.cpp" + break; + + case 7: // assignment: "identifier" "=" "identifier" "[" indices_list "]" +#line 69 "../parser.y" + { drv.add_lookup_entry(yystack_[5].value.as < std::string > (), yystack_[3].value.as < std::string > (), yystack_[1].value.as < std::vector> > ()); } +#line 674 "parser.cpp" + break; + + case 8: // exp: "number" +#line 73 "../parser.y" + { } +#line 680 "parser.cpp" + break; + + case 9: // exp: exp OPERATOR exp +#line 74 "../parser.y" + { drv.createNode(yystack_[1].value.as < std::string > (), 2); } +#line 686 "parser.cpp" + break; + + case 10: // exp: "(" exp ")" +#line 75 "../parser.y" + { } +#line 692 "parser.cpp" + break; + + case 11: // exp: "identifier" "(" list ")" +#line 76 "../parser.y" + { drv.createNode(yystack_[3].value.as < std::string > (), yystack_[1].value.as < int > ()); } +#line 698 "parser.cpp" + break; + + case 12: // exp: "identifier" "[" indices_list "]" +#line 77 "../parser.y" + { drv.createNode(yystack_[3].value.as < std::string > (), yystack_[1].value.as < std::vector> > ()); } +#line 704 "parser.cpp" + break; + + case 13: // exp: "identifier" +#line 78 "../parser.y" + { drv.createNode(yystack_[0].value.as < std::string > ()); } +#line 710 "parser.cpp" + break; + + case 14: // indices_list: %empty +#line 83 "../parser.y" + { yylhs.value.as < std::vector> > () = {}; } +#line 716 "parser.cpp" + break; + + case 15: // indices_list: indices_list "," index +#line 84 "../parser.y" + { yystack_[2].value.as < std::vector> > ().push_back(yystack_[0].value.as < std::tuple > ()); yylhs.value.as < std::vector> > () = yystack_[2].value.as < std::vector> > (); } +#line 722 "parser.cpp" + break; + + case 16: // indices_list: index +#line 85 "../parser.y" + { yylhs.value.as < std::vector> > () = {yystack_[0].value.as < std::tuple > ()}; } +#line 728 "parser.cpp" + break; + + case 17: // index: %empty +#line 89 "../parser.y" + { yylhs.value.as < std::tuple > () = {-1, -1, 1}; } +#line 734 "parser.cpp" + break; + + case 18: // index: "number" ":" "number" ":" "number" +#line 90 "../parser.y" + { yylhs.value.as < std::tuple > () = {yystack_[4].value.as < int > (), yystack_[2].value.as < int > (), yystack_[0].value.as < int > ()}; } +#line 740 "parser.cpp" + break; + + case 19: // index: ":" "number" ":" "number" +#line 91 "../parser.y" + { yylhs.value.as < std::tuple > () = {-1, yystack_[2].value.as < int > (), yystack_[0].value.as < int > ()}; } +#line 746 "parser.cpp" + break; + + case 20: // index: "number" ":" ":" "number" +#line 92 "../parser.y" + { yylhs.value.as < std::tuple > () = {yystack_[3].value.as < int > (), -1, yystack_[0].value.as < int > ()}; } +#line 752 "parser.cpp" + break; + + case 21: // index: "number" ":" "number" ":" +#line 93 "../parser.y" + { yylhs.value.as < std::tuple > () = {yystack_[3].value.as < int > (), yystack_[1].value.as < int > (), 1}; } +#line 758 "parser.cpp" + break; + + case 22: // index: "number" ":" "number" +#line 94 "../parser.y" + { yylhs.value.as < std::tuple > () = {yystack_[2].value.as < int > (), yystack_[0].value.as < int > (), 1}; } +#line 764 "parser.cpp" + break; + + case 23: // index: ":" ":" "number" +#line 95 "../parser.y" + { yylhs.value.as < std::tuple > () = {-1, -1, yystack_[0].value.as < int > ()}; } +#line 770 "parser.cpp" + break; + + case 24: // index: ":" "number" ":" +#line 96 "../parser.y" + { yylhs.value.as < std::tuple > () = {-1, yystack_[1].value.as < int > (), 1}; } +#line 776 "parser.cpp" + break; + + case 25: // index: ":" "number" +#line 97 "../parser.y" + { yylhs.value.as < std::tuple > () = {-1, yystack_[0].value.as < int > (), 1}; } +#line 782 "parser.cpp" + break; + + case 26: // index: "number" ":" ":" +#line 98 "../parser.y" + { yylhs.value.as < std::tuple > () = {yystack_[2].value.as < int > (), -1, 1}; } +#line 788 "parser.cpp" + break; + + case 27: // index: "number" ":" +#line 99 "../parser.y" + { yylhs.value.as < std::tuple > () = {yystack_[1].value.as < int > (), -1, 1}; } +#line 794 "parser.cpp" + break; + + case 28: // index: "number" +#line 100 "../parser.y" + { yylhs.value.as < std::tuple > () = {yystack_[0].value.as < int > (), yystack_[0].value.as < int > (), 1}; } +#line 800 "parser.cpp" + break; + + case 29: // list: %empty +#line 104 "../parser.y" + { yylhs.value.as < int > () = 0; } +#line 806 "parser.cpp" + break; + + case 30: // list: exp "," list +#line 105 "../parser.y" + { yylhs.value.as < int > () = yystack_[0].value.as < int > () + 1; } +#line 812 "parser.cpp" + break; + + case 31: // list: exp +#line 106 "../parser.y" + { yylhs.value.as < int > () = 1; } +#line 818 "parser.cpp" + break; + + +#line 822 "parser.cpp" + + default: + break; + } + } +#if YY_EXCEPTIONS + catch (const syntax_error& yyexc) + { + YYCDEBUG << "Caught exception: " << yyexc.what() << '\n'; + error (yyexc); + YYERROR; + } +#endif // YY_EXCEPTIONS + YY_SYMBOL_PRINT ("-> $$ =", yylhs); + yypop_ (yylen); + yylen = 0; + + // Shift the result of the reduction. + yypush_ (YY_NULLPTR, YY_MOVE (yylhs)); + } + goto yynewstate; + + + /*--------------------------------------. + | yyerrlab -- here on detecting error. | + `--------------------------------------*/ + yyerrlab: + // If not already recovering from an error, report this error. + if (!yyerrstatus_) + { + ++yynerrs_; + context yyctx (*this, yyla); + std::string msg = yysyntax_error_ (yyctx); + error (yyla.location, YY_MOVE (msg)); + } + + + yyerror_range[1].location = yyla.location; + if (yyerrstatus_ == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + // Return failure if at end of input. + if (yyla.kind () == symbol_kind::S_YYEOF) + YYABORT; + else if (!yyla.empty ()) + { + yy_destroy_ ("Error: discarding", yyla); + yyla.clear (); + } + } + + // Else will try to reuse lookahead token after shifting the error token. + goto yyerrlab1; + + + /*---------------------------------------------------. + | yyerrorlab -- error raised explicitly by YYERROR. | + `---------------------------------------------------*/ + yyerrorlab: + /* Pacify compilers when the user code never invokes YYERROR and + the label yyerrorlab therefore never appears in user code. */ + if (false) + YYERROR; + + /* Do not reclaim the symbols of the rule whose action triggered + this YYERROR. */ + yypop_ (yylen); + yylen = 0; + YY_STACK_PRINT (); + goto yyerrlab1; + + + /*-------------------------------------------------------------. + | yyerrlab1 -- common code for both syntax error and YYERROR. | + `-------------------------------------------------------------*/ + yyerrlab1: + yyerrstatus_ = 3; // Each real token shifted decrements this. + // Pop stack until we find a state that shifts the error token. + for (;;) + { + yyn = yypact_[+yystack_[0].state]; + if (!yy_pact_value_is_default_ (yyn)) + { + yyn += symbol_kind::S_YYerror; + if (0 <= yyn && yyn <= yylast_ + && yycheck_[yyn] == symbol_kind::S_YYerror) + { + yyn = yytable_[yyn]; + if (0 < yyn) + break; + } + } + + // Pop the current state because it cannot handle the error token. + if (yystack_.size () == 1) + YYABORT; + + yyerror_range[1].location = yystack_[0].location; + yy_destroy_ ("Error: popping", yystack_[0]); + yypop_ (); + YY_STACK_PRINT (); + } + { + stack_symbol_type error_token; + + yyerror_range[2].location = yyla.location; + YYLLOC_DEFAULT (error_token.location, yyerror_range, 2); + + // Shift the error token. + yy_lac_discard_ ("error recovery"); + error_token.state = state_type (yyn); + yypush_ ("Shifting", YY_MOVE (error_token)); + } + goto yynewstate; + + + /*-------------------------------------. + | yyacceptlab -- YYACCEPT comes here. | + `-------------------------------------*/ + yyacceptlab: + yyresult = 0; + goto yyreturn; + + + /*-----------------------------------. + | yyabortlab -- YYABORT comes here. | + `-----------------------------------*/ + yyabortlab: + yyresult = 1; + goto yyreturn; + + + /*-----------------------------------------------------. + | yyreturn -- parsing is finished, return the result. | + `-----------------------------------------------------*/ + yyreturn: + if (!yyla.empty ()) + yy_destroy_ ("Cleanup: discarding lookahead", yyla); + + /* Do not reclaim the symbols of the rule whose action triggered + this YYABORT or YYACCEPT. */ + yypop_ (yylen); + YY_STACK_PRINT (); + while (1 < yystack_.size ()) + { + yy_destroy_ ("Cleanup: popping", yystack_[0]); + yypop_ (); + } + + return yyresult; + } +#if YY_EXCEPTIONS + catch (...) + { + YYCDEBUG << "Exception caught: cleaning lookahead and stack\n"; + // Do not try to display the values of the reclaimed symbols, + // as their printers might throw an exception. + if (!yyla.empty ()) + yy_destroy_ (YY_NULLPTR, yyla); + + while (1 < yystack_.size ()) + { + yy_destroy_ (YY_NULLPTR, yystack_[0]); + yypop_ (); + } + throw; + } +#endif // YY_EXCEPTIONS + } + + void + parser::error (const syntax_error& yyexc) + { + error (yyexc.location, yyexc.what ()); + } + + const char * + parser::symbol_name (symbol_kind_type yysymbol) + { + static const char *const yy_sname[] = + { + "end of file", "error", "invalid token", "=", ",", ":", "(", ")", "[", + "]", "OPERATOR", "identifier", "VARNAME", "number", "$accept", "lines", + "assignment", "exp", "indices_list", "index", "list", YY_NULLPTR + }; + return yy_sname[yysymbol]; + } + + + + // parser::context. + parser::context::context (const parser& yyparser, const symbol_type& yyla) + : yyparser_ (yyparser) + , yyla_ (yyla) + {} + + int + parser::context::expected_tokens (symbol_kind_type yyarg[], int yyargn) const + { + // Actual number of expected tokens + int yycount = 0; + +#if YYDEBUG + // Execute LAC once. We don't care if it is successful, we + // only do it for the sake of debugging output. + if (!yyparser_.yy_lac_established_) + yyparser_.yy_lac_check_ (yyla_.kind ()); +#endif + + for (int yyx = 0; yyx < YYNTOKENS; ++yyx) + { + symbol_kind_type yysym = YY_CAST (symbol_kind_type, yyx); + if (yysym != symbol_kind::S_YYerror + && yysym != symbol_kind::S_YYUNDEF + && yyparser_.yy_lac_check_ (yysym)) + { + if (!yyarg) + ++yycount; + else if (yycount == yyargn) + return 0; + else + yyarg[yycount++] = yysym; + } + } + if (yyarg && yycount == 0 && 0 < yyargn) + yyarg[0] = symbol_kind::S_YYEMPTY; + return yycount; + } + + + + + bool + parser::yy_lac_check_ (symbol_kind_type yytoken) const + { + // Logically, the yylac_stack's lifetime is confined to this function. + // Clear it, to get rid of potential left-overs from previous call. + yylac_stack_.clear (); + // Reduce until we encounter a shift and thereby accept the token. +#if YYDEBUG + YYCDEBUG << "LAC: checking lookahead " << symbol_name (yytoken) << ':'; +#endif + std::ptrdiff_t lac_top = 0; + while (true) + { + state_type top_state = (yylac_stack_.empty () + ? yystack_[lac_top].state + : yylac_stack_.back ()); + int yyrule = yypact_[+top_state]; + if (yy_pact_value_is_default_ (yyrule) + || (yyrule += yytoken) < 0 || yylast_ < yyrule + || yycheck_[yyrule] != yytoken) + { + // Use the default action. + yyrule = yydefact_[+top_state]; + if (yyrule == 0) + { + YYCDEBUG << " Err\n"; + return false; + } + } + else + { + // Use the action from yytable. + yyrule = yytable_[yyrule]; + if (yy_table_value_is_error_ (yyrule)) + { + YYCDEBUG << " Err\n"; + return false; + } + if (0 < yyrule) + { + YYCDEBUG << " S" << yyrule << '\n'; + return true; + } + yyrule = -yyrule; + } + // By now we know we have to simulate a reduce. + YYCDEBUG << " R" << yyrule - 1; + // Pop the corresponding number of values from the stack. + { + std::ptrdiff_t yylen = yyr2_[yyrule]; + // First pop from the LAC stack as many tokens as possible. + std::ptrdiff_t lac_size = std::ptrdiff_t (yylac_stack_.size ()); + if (yylen < lac_size) + { + yylac_stack_.resize (std::size_t (lac_size - yylen)); + yylen = 0; + } + else if (lac_size) + { + yylac_stack_.clear (); + yylen -= lac_size; + } + // Only afterwards look at the main stack. + // We simulate popping elements by incrementing lac_top. + lac_top += yylen; + } + // Keep top_state in sync with the updated stack. + top_state = (yylac_stack_.empty () + ? yystack_[lac_top].state + : yylac_stack_.back ()); + // Push the resulting state of the reduction. + state_type state = yy_lr_goto_state_ (top_state, yyr1_[yyrule]); + YYCDEBUG << " G" << int (state); + yylac_stack_.push_back (state); + } + } + + // Establish the initial context if no initial context currently exists. + bool + parser::yy_lac_establish_ (symbol_kind_type yytoken) + { + /* Establish the initial context for the current lookahead if no initial + context is currently established. + + We define a context as a snapshot of the parser stacks. We define + the initial context for a lookahead as the context in which the + parser initially examines that lookahead in order to select a + syntactic action. Thus, if the lookahead eventually proves + syntactically unacceptable (possibly in a later context reached via a + series of reductions), the initial context can be used to determine + the exact set of tokens that would be syntactically acceptable in the + lookahead's place. Moreover, it is the context after which any + further semantic actions would be erroneous because they would be + determined by a syntactically unacceptable token. + + yy_lac_establish_ should be invoked when a reduction is about to be + performed in an inconsistent state (which, for the purposes of LAC, + includes consistent states that don't know they're consistent because + their default reductions have been disabled). + + For parse.lac=full, the implementation of yy_lac_establish_ is as + follows. If no initial context is currently established for the + current lookahead, then check if that lookahead can eventually be + shifted if syntactic actions continue from the current context. */ + if (yy_lac_established_) + return true; + else + { +#if YYDEBUG + YYCDEBUG << "LAC: initial context established for " + << symbol_name (yytoken) << '\n'; +#endif + yy_lac_established_ = true; + return yy_lac_check_ (yytoken); + } + } + + // Discard any previous initial lookahead context. + void + parser::yy_lac_discard_ (const char* event) + { + /* Discard any previous initial lookahead context because of Event, + which may be a lookahead change or an invalidation of the currently + established initial context for the current lookahead. + + The most common example of a lookahead change is a shift. An example + of both cases is syntax error recovery. That is, a syntax error + occurs when the lookahead is syntactically erroneous for the + currently established initial context, so error recovery manipulates + the parser stacks to try to find a new initial context in which the + current lookahead is syntactically acceptable. If it fails to find + such a context, it discards the lookahead. */ + if (yy_lac_established_) + { + YYCDEBUG << "LAC: initial context discarded due to " + << event << '\n'; + yy_lac_established_ = false; + } + } + + + int + parser::yy_syntax_error_arguments_ (const context& yyctx, + symbol_kind_type yyarg[], int yyargn) const + { + /* There are many possibilities here to consider: + - If this state is a consistent state with a default action, then + the only way this function was invoked is if the default action + is an error action. In that case, don't check for expected + tokens because there are none. + - The only way there can be no lookahead present (in yyla) is + if this state is a consistent state with a default action. + Thus, detecting the absence of a lookahead is sufficient to + determine that there is no unexpected or expected token to + report. In that case, just report a simple "syntax error". + - Don't assume there isn't a lookahead just because this state is + a consistent state with a default action. There might have + been a previous inconsistent state, consistent state with a + non-default action, or user semantic action that manipulated + yyla. (However, yyla is currently not documented for users.) + In the first two cases, it might appear that the current syntax + error should have been detected in the previous state when + yy_lac_check was invoked. However, at that time, there might + have been a different syntax error that discarded a different + initial context during error recovery, leaving behind the + current lookahead. + */ + + if (!yyctx.lookahead ().empty ()) + { + if (yyarg) + yyarg[0] = yyctx.token (); + int yyn = yyctx.expected_tokens (yyarg ? yyarg + 1 : yyarg, yyargn - 1); + return yyn + 1; + } + return 0; + } + + // Generate an error message. + std::string + parser::yysyntax_error_ (const context& yyctx) const + { + // Its maximum. + enum { YYARGS_MAX = 5 }; + // Arguments of yyformat. + symbol_kind_type yyarg[YYARGS_MAX]; + int yycount = yy_syntax_error_arguments_ (yyctx, yyarg, YYARGS_MAX); + + char const* yyformat = YY_NULLPTR; + switch (yycount) + { +#define YYCASE_(N, S) \ + case N: \ + yyformat = S; \ + break + default: // Avoid compiler warnings. + YYCASE_ (0, YY_("syntax error")); + YYCASE_ (1, YY_("syntax error, unexpected %s")); + YYCASE_ (2, YY_("syntax error, unexpected %s, expecting %s")); + YYCASE_ (3, YY_("syntax error, unexpected %s, expecting %s or %s")); + YYCASE_ (4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); + YYCASE_ (5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); +#undef YYCASE_ + } + + std::string yyres; + // Argument number. + std::ptrdiff_t yyi = 0; + for (char const* yyp = yyformat; *yyp; ++yyp) + if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount) + { + yyres += symbol_name (yyarg[yyi++]); + ++yyp; + } + else + yyres += *yyp; + return yyres; + } + + + const signed char parser::yypact_ninf_ = -7; + + const signed char parser::yytable_ninf_ = -1; + + const signed char + parser::yypact_[] = + { + 6, 9, 22, -7, 5, 6, 13, 27, -6, -4, + 9, -3, -7, -7, 9, -7, 30, 31, 14, 24, + -2, 35, 12, -7, -7, -3, -3, 9, -7, 28, + 37, 1, -3, -7, 23, 25, -7, -7, 32, 33, + 38, -7, -7, -7, -7, -7, 34, -7 + }; + + const signed char + parser::yydefact_[] = + { + 0, 0, 13, 8, 0, 0, 3, 13, 0, 0, + 29, 14, 1, 2, 0, 10, 5, 4, 31, 0, + 0, 28, 0, 16, 9, 14, 14, 29, 11, 0, + 25, 27, 17, 12, 0, 0, 30, 23, 24, 26, + 22, 15, 7, 6, 19, 20, 21, 18 + }; + + const signed char + parser::yypgoto_[] = + { + -7, 39, -7, -1, 11, 16, 26 + }; + + const signed char + parser::yydefgoto_[] = + { + 0, 4, 5, 6, 22, 23, 19 + }; + + const signed char + parser::yytable_[] = + { + 8, 15, 20, 29, 14, 12, 39, 16, 17, 18, + 21, 30, 1, 24, 40, 1, 32, 2, 27, 3, + 7, 33, 3, 14, 14, 9, 18, 32, 10, 32, + 11, 28, 42, 10, 43, 11, 34, 35, 25, 26, + 31, 37, 38, 46, 13, 44, 45, 47, 41, 0, + 0, 0, 0, 36 + }; + + const signed char + parser::yycheck_[] = + { + 1, 7, 5, 5, 10, 0, 5, 11, 12, 10, + 13, 13, 6, 14, 13, 6, 4, 11, 4, 13, + 11, 9, 13, 10, 10, 3, 27, 4, 6, 4, + 8, 7, 9, 6, 9, 8, 25, 26, 8, 8, + 5, 13, 5, 5, 5, 13, 13, 13, 32, -1, + -1, -1, -1, 27 + }; + + const signed char + parser::yystos_[] = + { + 0, 6, 11, 13, 15, 16, 17, 11, 17, 3, + 6, 8, 0, 15, 10, 7, 11, 12, 17, 20, + 5, 13, 18, 19, 17, 8, 8, 4, 7, 5, + 13, 5, 4, 9, 18, 18, 20, 13, 5, 5, + 13, 19, 9, 9, 13, 13, 5, 13 + }; + + const signed char + parser::yyr1_[] = + { + 0, 14, 15, 15, 16, 16, 16, 16, 17, 17, + 17, 17, 17, 17, 18, 18, 18, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, + 20, 20 + }; + + const signed char + parser::yyr2_[] = + { + 0, 2, 2, 1, 3, 3, 6, 6, 1, 3, + 3, 4, 4, 1, 0, 3, 1, 0, 5, 4, + 4, 4, 3, 3, 3, 2, 3, 2, 1, 0, + 3, 1 + }; + + + + +#if YYDEBUG + const signed char + parser::yyrline_[] = + { + 0, 61, 61, 62, 66, 67, 68, 69, 73, 74, + 75, 76, 77, 78, 83, 84, 85, 89, 90, 91, + 92, 93, 94, 95, 96, 97, 98, 99, 100, 104, + 105, 106 + }; + + void + parser::yy_stack_print_ () const + { + *yycdebug_ << "Stack now"; + for (stack_type::const_iterator + i = yystack_.begin (), + i_end = yystack_.end (); + i != i_end; ++i) + *yycdebug_ << ' ' << int (i->state); + *yycdebug_ << '\n'; + } + + void + parser::yy_reduce_print_ (int yyrule) const + { + int yylno = yyrline_[yyrule]; + int yynrhs = yyr2_[yyrule]; + // Print the symbols being reduced, and their result. + *yycdebug_ << "Reducing stack by rule " << yyrule - 1 + << " (line " << yylno << "):\n"; + // The symbols being reduced. + for (int yyi = 0; yyi < yynrhs; yyi++) + YY_SYMBOL_PRINT (" $" << yyi + 1 << " =", + yystack_[(yynrhs) - (yyi + 1)]); + } +#endif // YYDEBUG + + +#line 6 "../parser.y" +} } // adios2::detail +#line 1406 "parser.cpp" + +#line 107 "../parser.y" + + +void +adios2::detail::parser::error (const location_type& l, const std::string& m) +{ + std::cerr << l << ": " << m << '\n'; +} diff --git a/source/adios2/toolkit/derived/parser/pregen-source/parser.h b/source/adios2/toolkit/derived/parser/pregen-source/parser.h new file mode 100644 index 0000000000..819381e379 --- /dev/null +++ b/source/adios2/toolkit/derived/parser/pregen-source/parser.h @@ -0,0 +1,1609 @@ +// A Bison parser, made by GNU Bison 3.8.2. + +// Skeleton interface for Bison LALR(1) parsers in C++ + +// Copyright (C) 2002-2015, 2018-2021 Free Software Foundation, Inc. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// As a special exception, you may create a larger work that contains +// part or all of the Bison parser skeleton and distribute that work +// under terms of your choice, so long as that work isn't itself a +// parser generator using the skeleton or a modified version thereof +// as a parser skeleton. Alternatively, if you modify or redistribute +// the parser skeleton itself, you may (at your option) remove this +// special exception, which will cause the skeleton and the resulting +// Bison output files to be licensed under the GNU General Public +// License without this special exception. + +// This special exception was added by the Free Software Foundation in +// version 2.2 of Bison. + + +/** + ** \file parser.h + ** Define the adios2::detail::parser class. + */ + +// C++ LALR(1) parser skeleton written by Akim Demaille. + +// DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual, +// especially those whose name start with YY_ or yy_. They are +// private implementation details that can be changed or removed. + +#ifndef YY_YY_PARSER_H_INCLUDED +# define YY_YY_PARSER_H_INCLUDED +// "%code requires" blocks. +#line 11 "../parser.y" + + #include + #include + #include + namespace adios2 + { + namespace detail + { + class ASTDriver; + } + } + +#line 62 "parser.h" + +# include +# include // std::abort +# include +# include +# include +# include + +#if defined __cplusplus +# define YY_CPLUSPLUS __cplusplus +#else +# define YY_CPLUSPLUS 199711L +#endif + +// Support move semantics when possible. +#if 201103L <= YY_CPLUSPLUS +# define YY_MOVE std::move +# define YY_MOVE_OR_COPY move +# define YY_MOVE_REF(Type) Type&& +# define YY_RVREF(Type) Type&& +# define YY_COPY(Type) Type +#else +# define YY_MOVE +# define YY_MOVE_OR_COPY copy +# define YY_MOVE_REF(Type) Type& +# define YY_RVREF(Type) const Type& +# define YY_COPY(Type) const Type& +#endif + +// Support noexcept when possible. +#if 201103L <= YY_CPLUSPLUS +# define YY_NOEXCEPT noexcept +# define YY_NOTHROW +#else +# define YY_NOEXCEPT +# define YY_NOTHROW throw () +#endif + +// Support constexpr when possible. +#if 201703 <= YY_CPLUSPLUS +# define YY_CONSTEXPR constexpr +#else +# define YY_CONSTEXPR +#endif +# include "location.hh" +#include +#ifndef YY_ASSERT +# include +# define YY_ASSERT assert +#endif + + +#ifndef YY_ATTRIBUTE_PURE +# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__) +# define YY_ATTRIBUTE_PURE __attribute__ ((__pure__)) +# else +# define YY_ATTRIBUTE_PURE +# endif +#endif + +#ifndef YY_ATTRIBUTE_UNUSED +# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__) +# define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) +# else +# define YY_ATTRIBUTE_UNUSED +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YY_USE(E) ((void) (E)) +#else +# define YY_USE(E) /* empty */ +#endif + +/* Suppress an incorrect diagnostic about yylval being uninitialized. */ +#if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__ +# if __GNUC__ * 100 + __GNUC_MINOR__ < 407 +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") +# else +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \ + _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") +# endif +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ + _Pragma ("GCC diagnostic pop") +#else +# define YY_INITIAL_VALUE(Value) Value +#endif +#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_END +#endif +#ifndef YY_INITIAL_VALUE +# define YY_INITIAL_VALUE(Value) /* Nothing. */ +#endif + +#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__ +# define YY_IGNORE_USELESS_CAST_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"") +# define YY_IGNORE_USELESS_CAST_END \ + _Pragma ("GCC diagnostic pop") +#endif +#ifndef YY_IGNORE_USELESS_CAST_BEGIN +# define YY_IGNORE_USELESS_CAST_BEGIN +# define YY_IGNORE_USELESS_CAST_END +#endif + +# ifndef YY_CAST +# ifdef __cplusplus +# define YY_CAST(Type, Val) static_cast (Val) +# define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast (Val) +# else +# define YY_CAST(Type, Val) ((Type) (Val)) +# define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val)) +# endif +# endif +# ifndef YY_NULLPTR +# if defined __cplusplus +# if 201103L <= __cplusplus +# define YY_NULLPTR nullptr +# else +# define YY_NULLPTR 0 +# endif +# else +# define YY_NULLPTR ((void*)0) +# endif +# endif + +/* Debug traces. */ +#ifndef YYDEBUG +# define YYDEBUG 1 +#endif + +#line 6 "../parser.y" +namespace adios2 { namespace detail { +#line 203 "parser.h" + + + + + /// A Bison parser. + class parser + { + public: +#ifdef YYSTYPE +# ifdef __GNUC__ +# pragma GCC message "bison: do not #define YYSTYPE in C++, use %define api.value.type" +# endif + typedef YYSTYPE value_type; +#else + /// A buffer to store and retrieve objects. + /// + /// Sort of a variant, but does not keep track of the nature + /// of the stored data, since that knowledge is available + /// via the current parser state. + class value_type + { + public: + /// Type of *this. + typedef value_type self_type; + + /// Empty construction. + value_type () YY_NOEXCEPT + : yyraw_ () + , yytypeid_ (YY_NULLPTR) + {} + + /// Construct and fill. + template + value_type (YY_RVREF (T) t) + : yytypeid_ (&typeid (T)) + { + YY_ASSERT (sizeof (T) <= size); + new (yyas_ ()) T (YY_MOVE (t)); + } + +#if 201103L <= YY_CPLUSPLUS + /// Non copyable. + value_type (const self_type&) = delete; + /// Non copyable. + self_type& operator= (const self_type&) = delete; +#endif + + /// Destruction, allowed only if empty. + ~value_type () YY_NOEXCEPT + { + YY_ASSERT (!yytypeid_); + } + +# if 201103L <= YY_CPLUSPLUS + /// Instantiate a \a T in here from \a t. + template + T& + emplace (U&&... u) + { + YY_ASSERT (!yytypeid_); + YY_ASSERT (sizeof (T) <= size); + yytypeid_ = & typeid (T); + return *new (yyas_ ()) T (std::forward (u)...); + } +# else + /// Instantiate an empty \a T in here. + template + T& + emplace () + { + YY_ASSERT (!yytypeid_); + YY_ASSERT (sizeof (T) <= size); + yytypeid_ = & typeid (T); + return *new (yyas_ ()) T (); + } + + /// Instantiate a \a T in here from \a t. + template + T& + emplace (const T& t) + { + YY_ASSERT (!yytypeid_); + YY_ASSERT (sizeof (T) <= size); + yytypeid_ = & typeid (T); + return *new (yyas_ ()) T (t); + } +# endif + + /// Instantiate an empty \a T in here. + /// Obsolete, use emplace. + template + T& + build () + { + return emplace (); + } + + /// Instantiate a \a T in here from \a t. + /// Obsolete, use emplace. + template + T& + build (const T& t) + { + return emplace (t); + } + + /// Accessor to a built \a T. + template + T& + as () YY_NOEXCEPT + { + YY_ASSERT (yytypeid_); + YY_ASSERT (*yytypeid_ == typeid (T)); + YY_ASSERT (sizeof (T) <= size); + return *yyas_ (); + } + + /// Const accessor to a built \a T (for %printer). + template + const T& + as () const YY_NOEXCEPT + { + YY_ASSERT (yytypeid_); + YY_ASSERT (*yytypeid_ == typeid (T)); + YY_ASSERT (sizeof (T) <= size); + return *yyas_ (); + } + + /// Swap the content with \a that, of same type. + /// + /// Both variants must be built beforehand, because swapping the actual + /// data requires reading it (with as()), and this is not possible on + /// unconstructed variants: it would require some dynamic testing, which + /// should not be the variant's responsibility. + /// Swapping between built and (possibly) non-built is done with + /// self_type::move (). + template + void + swap (self_type& that) YY_NOEXCEPT + { + YY_ASSERT (yytypeid_); + YY_ASSERT (*yytypeid_ == *that.yytypeid_); + std::swap (as (), that.as ()); + } + + /// Move the content of \a that to this. + /// + /// Destroys \a that. + template + void + move (self_type& that) + { +# if 201103L <= YY_CPLUSPLUS + emplace (std::move (that.as ())); +# else + emplace (); + swap (that); +# endif + that.destroy (); + } + +# if 201103L <= YY_CPLUSPLUS + /// Move the content of \a that to this. + template + void + move (self_type&& that) + { + emplace (std::move (that.as ())); + that.destroy (); + } +#endif + + /// Copy the content of \a that to this. + template + void + copy (const self_type& that) + { + emplace (that.as ()); + } + + /// Destroy the stored \a T. + template + void + destroy () + { + as ().~T (); + yytypeid_ = YY_NULLPTR; + } + + private: +#if YY_CPLUSPLUS < 201103L + /// Non copyable. + value_type (const self_type&); + /// Non copyable. + self_type& operator= (const self_type&); +#endif + + /// Accessor to raw memory as \a T. + template + T* + yyas_ () YY_NOEXCEPT + { + void *yyp = yyraw_; + return static_cast (yyp); + } + + /// Const accessor to raw memory as \a T. + template + const T* + yyas_ () const YY_NOEXCEPT + { + const void *yyp = yyraw_; + return static_cast (yyp); + } + + /// An auxiliary type to compute the largest semantic type. + union union_type + { + // "number" + // list + char dummy1[sizeof (int)]; + + // OPERATOR + // "identifier" + // VARNAME + char dummy2[sizeof (std::string)]; + + // index + char dummy3[sizeof (std::tuple)]; + + // indices_list + char dummy4[sizeof (std::vector>)]; + }; + + /// The size of the largest semantic type. + enum { size = sizeof (union_type) }; + + /// A buffer to store semantic values. + union + { + /// Strongest alignment constraints. + long double yyalign_me_; + /// A buffer large enough to store any of the semantic values. + char yyraw_[size]; + }; + + /// Whether the content is built: if defined, the name of the stored type. + const std::type_info *yytypeid_; + }; + +#endif + /// Backward compatibility (Bison 3.8). + typedef value_type semantic_type; + + /// Symbol locations. + typedef location location_type; + + /// Syntax errors thrown from user actions. + struct syntax_error : std::runtime_error + { + syntax_error (const location_type& l, const std::string& m) + : std::runtime_error (m) + , location (l) + {} + + syntax_error (const syntax_error& s) + : std::runtime_error (s.what ()) + , location (s.location) + {} + + ~syntax_error () YY_NOEXCEPT YY_NOTHROW; + + location_type location; + }; + + /// Token kinds. + struct token + { + enum token_kind_type + { + TOK_YYEMPTY = -2, + TOK_YYEOF = 0, // "end of file" + TOK_YYerror = 1, // error + TOK_YYUNDEF = 2, // "invalid token" + TOK_ASSIGN = 3, // "=" + TOK_COMMA = 4, // "," + TOK_COLON = 5, // ":" + TOK_L_PAREN = 6, // "(" + TOK_R_PAREN = 7, // ")" + TOK_L_BRACE = 8, // "[" + TOK_R_BRACE = 9, // "]" + TOK_OPERATOR = 10, // OPERATOR + TOK_IDENTIFIER = 11, // "identifier" + TOK_VARNAME = 12, // VARNAME + TOK_INT = 13 // "number" + }; + /// Backward compatibility alias (Bison 3.6). + typedef token_kind_type yytokentype; + }; + + /// Token kind, as returned by yylex. + typedef token::token_kind_type token_kind_type; + + /// Backward compatibility alias (Bison 3.6). + typedef token_kind_type token_type; + + /// Symbol kinds. + struct symbol_kind + { + enum symbol_kind_type + { + YYNTOKENS = 14, ///< Number of tokens. + S_YYEMPTY = -2, + S_YYEOF = 0, // "end of file" + S_YYerror = 1, // error + S_YYUNDEF = 2, // "invalid token" + S_ASSIGN = 3, // "=" + S_COMMA = 4, // "," + S_COLON = 5, // ":" + S_L_PAREN = 6, // "(" + S_R_PAREN = 7, // ")" + S_L_BRACE = 8, // "[" + S_R_BRACE = 9, // "]" + S_OPERATOR = 10, // OPERATOR + S_IDENTIFIER = 11, // "identifier" + S_VARNAME = 12, // VARNAME + S_INT = 13, // "number" + S_YYACCEPT = 14, // $accept + S_lines = 15, // lines + S_assignment = 16, // assignment + S_exp = 17, // exp + S_indices_list = 18, // indices_list + S_index = 19, // index + S_list = 20 // list + }; + }; + + /// (Internal) symbol kind. + typedef symbol_kind::symbol_kind_type symbol_kind_type; + + /// The number of tokens. + static const symbol_kind_type YYNTOKENS = symbol_kind::YYNTOKENS; + + /// A complete symbol. + /// + /// Expects its Base type to provide access to the symbol kind + /// via kind (). + /// + /// Provide access to semantic value and location. + template + struct basic_symbol : Base + { + /// Alias to Base. + typedef Base super_type; + + /// Default constructor. + basic_symbol () YY_NOEXCEPT + : value () + , location () + {} + +#if 201103L <= YY_CPLUSPLUS + /// Move constructor. + basic_symbol (basic_symbol&& that) + : Base (std::move (that)) + , value () + , location (std::move (that.location)) + { + switch (this->kind ()) + { + case symbol_kind::S_INT: // "number" + case symbol_kind::S_list: // list + value.move< int > (std::move (that.value)); + break; + + case symbol_kind::S_OPERATOR: // OPERATOR + case symbol_kind::S_IDENTIFIER: // "identifier" + case symbol_kind::S_VARNAME: // VARNAME + value.move< std::string > (std::move (that.value)); + break; + + case symbol_kind::S_index: // index + value.move< std::tuple > (std::move (that.value)); + break; + + case symbol_kind::S_indices_list: // indices_list + value.move< std::vector> > (std::move (that.value)); + break; + + default: + break; + } + + } +#endif + + /// Copy constructor. + basic_symbol (const basic_symbol& that); + + /// Constructors for typed symbols. +#if 201103L <= YY_CPLUSPLUS + basic_symbol (typename Base::kind_type t, location_type&& l) + : Base (t) + , location (std::move (l)) + {} +#else + basic_symbol (typename Base::kind_type t, const location_type& l) + : Base (t) + , location (l) + {} +#endif + +#if 201103L <= YY_CPLUSPLUS + basic_symbol (typename Base::kind_type t, int&& v, location_type&& l) + : Base (t) + , value (std::move (v)) + , location (std::move (l)) + {} +#else + basic_symbol (typename Base::kind_type t, const int& v, const location_type& l) + : Base (t) + , value (v) + , location (l) + {} +#endif + +#if 201103L <= YY_CPLUSPLUS + basic_symbol (typename Base::kind_type t, std::string&& v, location_type&& l) + : Base (t) + , value (std::move (v)) + , location (std::move (l)) + {} +#else + basic_symbol (typename Base::kind_type t, const std::string& v, const location_type& l) + : Base (t) + , value (v) + , location (l) + {} +#endif + +#if 201103L <= YY_CPLUSPLUS + basic_symbol (typename Base::kind_type t, std::tuple&& v, location_type&& l) + : Base (t) + , value (std::move (v)) + , location (std::move (l)) + {} +#else + basic_symbol (typename Base::kind_type t, const std::tuple& v, const location_type& l) + : Base (t) + , value (v) + , location (l) + {} +#endif + +#if 201103L <= YY_CPLUSPLUS + basic_symbol (typename Base::kind_type t, std::vector>&& v, location_type&& l) + : Base (t) + , value (std::move (v)) + , location (std::move (l)) + {} +#else + basic_symbol (typename Base::kind_type t, const std::vector>& v, const location_type& l) + : Base (t) + , value (v) + , location (l) + {} +#endif + + /// Destroy the symbol. + ~basic_symbol () + { + clear (); + } + + + + /// Destroy contents, and record that is empty. + void clear () YY_NOEXCEPT + { + // User destructor. + symbol_kind_type yykind = this->kind (); + basic_symbol& yysym = *this; + (void) yysym; + switch (yykind) + { + default: + break; + } + + // Value type destructor. +switch (yykind) + { + case symbol_kind::S_INT: // "number" + case symbol_kind::S_list: // list + value.template destroy< int > (); + break; + + case symbol_kind::S_OPERATOR: // OPERATOR + case symbol_kind::S_IDENTIFIER: // "identifier" + case symbol_kind::S_VARNAME: // VARNAME + value.template destroy< std::string > (); + break; + + case symbol_kind::S_index: // index + value.template destroy< std::tuple > (); + break; + + case symbol_kind::S_indices_list: // indices_list + value.template destroy< std::vector> > (); + break; + + default: + break; + } + + Base::clear (); + } + + /// The user-facing name of this symbol. + const char *name () const YY_NOEXCEPT + { + return parser::symbol_name (this->kind ()); + } + + /// Backward compatibility (Bison 3.6). + symbol_kind_type type_get () const YY_NOEXCEPT; + + /// Whether empty. + bool empty () const YY_NOEXCEPT; + + /// Destructive move, \a s is emptied into this. + void move (basic_symbol& s); + + /// The semantic value. + value_type value; + + /// The location. + location_type location; + + private: +#if YY_CPLUSPLUS < 201103L + /// Assignment operator. + basic_symbol& operator= (const basic_symbol& that); +#endif + }; + + /// Type access provider for token (enum) based symbols. + struct by_kind + { + /// The symbol kind as needed by the constructor. + typedef token_kind_type kind_type; + + /// Default constructor. + by_kind () YY_NOEXCEPT; + +#if 201103L <= YY_CPLUSPLUS + /// Move constructor. + by_kind (by_kind&& that) YY_NOEXCEPT; +#endif + + /// Copy constructor. + by_kind (const by_kind& that) YY_NOEXCEPT; + + /// Constructor from (external) token numbers. + by_kind (kind_type t) YY_NOEXCEPT; + + + + /// Record that this symbol is empty. + void clear () YY_NOEXCEPT; + + /// Steal the symbol kind from \a that. + void move (by_kind& that); + + /// The (internal) type number (corresponding to \a type). + /// \a empty when empty. + symbol_kind_type kind () const YY_NOEXCEPT; + + /// Backward compatibility (Bison 3.6). + symbol_kind_type type_get () const YY_NOEXCEPT; + + /// The symbol kind. + /// \a S_YYEMPTY when empty. + symbol_kind_type kind_; + }; + + /// Backward compatibility for a private implementation detail (Bison 3.6). + typedef by_kind by_type; + + /// "External" symbols: returned by the scanner. + struct symbol_type : basic_symbol + { + /// Superclass. + typedef basic_symbol super_type; + + /// Empty symbol. + symbol_type () YY_NOEXCEPT {} + + /// Constructor for valueless symbols, and symbols from each type. +#if 201103L <= YY_CPLUSPLUS + symbol_type (int tok, location_type l) + : super_type (token_kind_type (tok), std::move (l)) +#else + symbol_type (int tok, const location_type& l) + : super_type (token_kind_type (tok), l) +#endif + { +#if !defined _MSC_VER || defined __clang__ + YY_ASSERT (tok == token::TOK_YYEOF + || (token::TOK_YYerror <= tok && tok <= token::TOK_R_BRACE)); +#endif + } +#if 201103L <= YY_CPLUSPLUS + symbol_type (int tok, int v, location_type l) + : super_type (token_kind_type (tok), std::move (v), std::move (l)) +#else + symbol_type (int tok, const int& v, const location_type& l) + : super_type (token_kind_type (tok), v, l) +#endif + { +#if !defined _MSC_VER || defined __clang__ + YY_ASSERT (tok == token::TOK_INT); +#endif + } +#if 201103L <= YY_CPLUSPLUS + symbol_type (int tok, std::string v, location_type l) + : super_type (token_kind_type (tok), std::move (v), std::move (l)) +#else + symbol_type (int tok, const std::string& v, const location_type& l) + : super_type (token_kind_type (tok), v, l) +#endif + { +#if !defined _MSC_VER || defined __clang__ + YY_ASSERT ((token::TOK_OPERATOR <= tok && tok <= token::TOK_VARNAME)); +#endif + } + }; + + /// Build a parser object. + parser (ASTDriver& drv_yyarg); + virtual ~parser (); + +#if 201103L <= YY_CPLUSPLUS + /// Non copyable. + parser (const parser&) = delete; + /// Non copyable. + parser& operator= (const parser&) = delete; +#endif + + /// Parse. An alias for parse (). + /// \returns 0 iff parsing succeeded. + int operator() (); + + /// Parse. + /// \returns 0 iff parsing succeeded. + virtual int parse (); + +#if YYDEBUG + /// The current debugging stream. + std::ostream& debug_stream () const YY_ATTRIBUTE_PURE; + /// Set the current debugging stream. + void set_debug_stream (std::ostream &); + + /// Type for debugging levels. + typedef int debug_level_type; + /// The current debugging level. + debug_level_type debug_level () const YY_ATTRIBUTE_PURE; + /// Set the current debugging level. + void set_debug_level (debug_level_type l); +#endif + + /// Report a syntax error. + /// \param loc where the syntax error is found. + /// \param msg a description of the syntax error. + virtual void error (const location_type& loc, const std::string& msg); + + /// Report a syntax error. + void error (const syntax_error& err); + + /// The user-facing name of the symbol whose (internal) number is + /// YYSYMBOL. No bounds checking. + static const char *symbol_name (symbol_kind_type yysymbol); + + // Implementation of make_symbol for each token kind. +#if 201103L <= YY_CPLUSPLUS + static + symbol_type + make_YYEOF (location_type l) + { + return symbol_type (token::TOK_YYEOF, std::move (l)); + } +#else + static + symbol_type + make_YYEOF (const location_type& l) + { + return symbol_type (token::TOK_YYEOF, l); + } +#endif +#if 201103L <= YY_CPLUSPLUS + static + symbol_type + make_YYerror (location_type l) + { + return symbol_type (token::TOK_YYerror, std::move (l)); + } +#else + static + symbol_type + make_YYerror (const location_type& l) + { + return symbol_type (token::TOK_YYerror, l); + } +#endif +#if 201103L <= YY_CPLUSPLUS + static + symbol_type + make_YYUNDEF (location_type l) + { + return symbol_type (token::TOK_YYUNDEF, std::move (l)); + } +#else + static + symbol_type + make_YYUNDEF (const location_type& l) + { + return symbol_type (token::TOK_YYUNDEF, l); + } +#endif +#if 201103L <= YY_CPLUSPLUS + static + symbol_type + make_ASSIGN (location_type l) + { + return symbol_type (token::TOK_ASSIGN, std::move (l)); + } +#else + static + symbol_type + make_ASSIGN (const location_type& l) + { + return symbol_type (token::TOK_ASSIGN, l); + } +#endif +#if 201103L <= YY_CPLUSPLUS + static + symbol_type + make_COMMA (location_type l) + { + return symbol_type (token::TOK_COMMA, std::move (l)); + } +#else + static + symbol_type + make_COMMA (const location_type& l) + { + return symbol_type (token::TOK_COMMA, l); + } +#endif +#if 201103L <= YY_CPLUSPLUS + static + symbol_type + make_COLON (location_type l) + { + return symbol_type (token::TOK_COLON, std::move (l)); + } +#else + static + symbol_type + make_COLON (const location_type& l) + { + return symbol_type (token::TOK_COLON, l); + } +#endif +#if 201103L <= YY_CPLUSPLUS + static + symbol_type + make_L_PAREN (location_type l) + { + return symbol_type (token::TOK_L_PAREN, std::move (l)); + } +#else + static + symbol_type + make_L_PAREN (const location_type& l) + { + return symbol_type (token::TOK_L_PAREN, l); + } +#endif +#if 201103L <= YY_CPLUSPLUS + static + symbol_type + make_R_PAREN (location_type l) + { + return symbol_type (token::TOK_R_PAREN, std::move (l)); + } +#else + static + symbol_type + make_R_PAREN (const location_type& l) + { + return symbol_type (token::TOK_R_PAREN, l); + } +#endif +#if 201103L <= YY_CPLUSPLUS + static + symbol_type + make_L_BRACE (location_type l) + { + return symbol_type (token::TOK_L_BRACE, std::move (l)); + } +#else + static + symbol_type + make_L_BRACE (const location_type& l) + { + return symbol_type (token::TOK_L_BRACE, l); + } +#endif +#if 201103L <= YY_CPLUSPLUS + static + symbol_type + make_R_BRACE (location_type l) + { + return symbol_type (token::TOK_R_BRACE, std::move (l)); + } +#else + static + symbol_type + make_R_BRACE (const location_type& l) + { + return symbol_type (token::TOK_R_BRACE, l); + } +#endif +#if 201103L <= YY_CPLUSPLUS + static + symbol_type + make_OPERATOR (std::string v, location_type l) + { + return symbol_type (token::TOK_OPERATOR, std::move (v), std::move (l)); + } +#else + static + symbol_type + make_OPERATOR (const std::string& v, const location_type& l) + { + return symbol_type (token::TOK_OPERATOR, v, l); + } +#endif +#if 201103L <= YY_CPLUSPLUS + static + symbol_type + make_IDENTIFIER (std::string v, location_type l) + { + return symbol_type (token::TOK_IDENTIFIER, std::move (v), std::move (l)); + } +#else + static + symbol_type + make_IDENTIFIER (const std::string& v, const location_type& l) + { + return symbol_type (token::TOK_IDENTIFIER, v, l); + } +#endif +#if 201103L <= YY_CPLUSPLUS + static + symbol_type + make_VARNAME (std::string v, location_type l) + { + return symbol_type (token::TOK_VARNAME, std::move (v), std::move (l)); + } +#else + static + symbol_type + make_VARNAME (const std::string& v, const location_type& l) + { + return symbol_type (token::TOK_VARNAME, v, l); + } +#endif +#if 201103L <= YY_CPLUSPLUS + static + symbol_type + make_INT (int v, location_type l) + { + return symbol_type (token::TOK_INT, std::move (v), std::move (l)); + } +#else + static + symbol_type + make_INT (const int& v, const location_type& l) + { + return symbol_type (token::TOK_INT, v, l); + } +#endif + + + class context + { + public: + context (const parser& yyparser, const symbol_type& yyla); + const symbol_type& lookahead () const YY_NOEXCEPT { return yyla_; } + symbol_kind_type token () const YY_NOEXCEPT { return yyla_.kind (); } + const location_type& location () const YY_NOEXCEPT { return yyla_.location; } + + /// Put in YYARG at most YYARGN of the expected tokens, and return the + /// number of tokens stored in YYARG. If YYARG is null, return the + /// number of expected tokens (guaranteed to be less than YYNTOKENS). + int expected_tokens (symbol_kind_type yyarg[], int yyargn) const; + + private: + const parser& yyparser_; + const symbol_type& yyla_; + }; + + private: +#if YY_CPLUSPLUS < 201103L + /// Non copyable. + parser (const parser&); + /// Non copyable. + parser& operator= (const parser&); +#endif + + /// Check the lookahead yytoken. + /// \returns true iff the token will be eventually shifted. + bool yy_lac_check_ (symbol_kind_type yytoken) const; + /// Establish the initial context if no initial context currently exists. + /// \returns true iff the token will be eventually shifted. + bool yy_lac_establish_ (symbol_kind_type yytoken); + /// Discard any previous initial lookahead context because of event. + /// \param event the event which caused the lookahead to be discarded. + /// Only used for debbuging output. + void yy_lac_discard_ (const char* event); + + /// Stored state numbers (used for stacks). + typedef signed char state_type; + + /// The arguments of the error message. + int yy_syntax_error_arguments_ (const context& yyctx, + symbol_kind_type yyarg[], int yyargn) const; + + /// Generate an error message. + /// \param yyctx the context in which the error occurred. + virtual std::string yysyntax_error_ (const context& yyctx) const; + /// Compute post-reduction state. + /// \param yystate the current state + /// \param yysym the nonterminal to push on the stack + static state_type yy_lr_goto_state_ (state_type yystate, int yysym); + + /// Whether the given \c yypact_ value indicates a defaulted state. + /// \param yyvalue the value to check + static bool yy_pact_value_is_default_ (int yyvalue) YY_NOEXCEPT; + + /// Whether the given \c yytable_ value indicates a syntax error. + /// \param yyvalue the value to check + static bool yy_table_value_is_error_ (int yyvalue) YY_NOEXCEPT; + + static const signed char yypact_ninf_; + static const signed char yytable_ninf_; + + /// Convert a scanner token kind \a t to a symbol kind. + /// In theory \a t should be a token_kind_type, but character literals + /// are valid, yet not members of the token_kind_type enum. + static symbol_kind_type yytranslate_ (int t) YY_NOEXCEPT; + + + + // Tables. + // YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + // STATE-NUM. + static const signed char yypact_[]; + + // YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. + // Performed when YYTABLE does not specify something else to do. Zero + // means the default is an error. + static const signed char yydefact_[]; + + // YYPGOTO[NTERM-NUM]. + static const signed char yypgoto_[]; + + // YYDEFGOTO[NTERM-NUM]. + static const signed char yydefgoto_[]; + + // YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If + // positive, shift that token. If negative, reduce the rule whose + // number is the opposite. If YYTABLE_NINF, syntax error. + static const signed char yytable_[]; + + static const signed char yycheck_[]; + + // YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of + // state STATE-NUM. + static const signed char yystos_[]; + + // YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. + static const signed char yyr1_[]; + + // YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. + static const signed char yyr2_[]; + + +#if YYDEBUG + // YYRLINE[YYN] -- Source line where rule number YYN was defined. + static const signed char yyrline_[]; + /// Report on the debug stream that the rule \a r is going to be reduced. + virtual void yy_reduce_print_ (int r) const; + /// Print the state stack on the debug stream. + virtual void yy_stack_print_ () const; + + /// Debugging level. + int yydebug_; + /// Debug stream. + std::ostream* yycdebug_; + + /// \brief Display a symbol kind, value and location. + /// \param yyo The output stream. + /// \param yysym The symbol. + template + void yy_print_ (std::ostream& yyo, const basic_symbol& yysym) const; +#endif + + /// \brief Reclaim the memory associated to a symbol. + /// \param yymsg Why this token is reclaimed. + /// If null, print nothing. + /// \param yysym The symbol. + template + void yy_destroy_ (const char* yymsg, basic_symbol& yysym) const; + + private: + /// Type access provider for state based symbols. + struct by_state + { + /// Default constructor. + by_state () YY_NOEXCEPT; + + /// The symbol kind as needed by the constructor. + typedef state_type kind_type; + + /// Constructor. + by_state (kind_type s) YY_NOEXCEPT; + + /// Copy constructor. + by_state (const by_state& that) YY_NOEXCEPT; + + /// Record that this symbol is empty. + void clear () YY_NOEXCEPT; + + /// Steal the symbol kind from \a that. + void move (by_state& that); + + /// The symbol kind (corresponding to \a state). + /// \a symbol_kind::S_YYEMPTY when empty. + symbol_kind_type kind () const YY_NOEXCEPT; + + /// The state number used to denote an empty symbol. + /// We use the initial state, as it does not have a value. + enum { empty_state = 0 }; + + /// The state. + /// \a empty when empty. + state_type state; + }; + + /// "Internal" symbol: element of the stack. + struct stack_symbol_type : basic_symbol + { + /// Superclass. + typedef basic_symbol super_type; + /// Construct an empty symbol. + stack_symbol_type (); + /// Move or copy construction. + stack_symbol_type (YY_RVREF (stack_symbol_type) that); + /// Steal the contents from \a sym to build this. + stack_symbol_type (state_type s, YY_MOVE_REF (symbol_type) sym); +#if YY_CPLUSPLUS < 201103L + /// Assignment, needed by push_back by some old implementations. + /// Moves the contents of that. + stack_symbol_type& operator= (stack_symbol_type& that); + + /// Assignment, needed by push_back by other implementations. + /// Needed by some other old implementations. + stack_symbol_type& operator= (const stack_symbol_type& that); +#endif + }; + + /// A stack with random access from its top. + template > + class stack + { + public: + // Hide our reversed order. + typedef typename S::iterator iterator; + typedef typename S::const_iterator const_iterator; + typedef typename S::size_type size_type; + typedef typename std::ptrdiff_t index_type; + + stack (size_type n = 200) YY_NOEXCEPT + : seq_ (n) + {} + +#if 201103L <= YY_CPLUSPLUS + /// Non copyable. + stack (const stack&) = delete; + /// Non copyable. + stack& operator= (const stack&) = delete; +#endif + + /// Random access. + /// + /// Index 0 returns the topmost element. + const T& + operator[] (index_type i) const + { + return seq_[size_type (size () - 1 - i)]; + } + + /// Random access. + /// + /// Index 0 returns the topmost element. + T& + operator[] (index_type i) + { + return seq_[size_type (size () - 1 - i)]; + } + + /// Steal the contents of \a t. + /// + /// Close to move-semantics. + void + push (YY_MOVE_REF (T) t) + { + seq_.push_back (T ()); + operator[] (0).move (t); + } + + /// Pop elements from the stack. + void + pop (std::ptrdiff_t n = 1) YY_NOEXCEPT + { + for (; 0 < n; --n) + seq_.pop_back (); + } + + /// Pop all elements from the stack. + void + clear () YY_NOEXCEPT + { + seq_.clear (); + } + + /// Number of elements on the stack. + index_type + size () const YY_NOEXCEPT + { + return index_type (seq_.size ()); + } + + /// Iterator on top of the stack (going downwards). + const_iterator + begin () const YY_NOEXCEPT + { + return seq_.begin (); + } + + /// Bottom of the stack. + const_iterator + end () const YY_NOEXCEPT + { + return seq_.end (); + } + + /// Present a slice of the top of a stack. + class slice + { + public: + slice (const stack& stack, index_type range) YY_NOEXCEPT + : stack_ (stack) + , range_ (range) + {} + + const T& + operator[] (index_type i) const + { + return stack_[range_ - i]; + } + + private: + const stack& stack_; + index_type range_; + }; + + private: +#if YY_CPLUSPLUS < 201103L + /// Non copyable. + stack (const stack&); + /// Non copyable. + stack& operator= (const stack&); +#endif + /// The wrapped container. + S seq_; + }; + + + /// Stack type. + typedef stack stack_type; + + /// The stack. + stack_type yystack_; + /// The stack for LAC. + /// Logically, the yy_lac_stack's lifetime is confined to the function + /// yy_lac_check_. We just store it as a member of this class to hold + /// on to the memory and to avoid frequent reallocations. + /// Since yy_lac_check_ is const, this member must be mutable. + mutable std::vector yylac_stack_; + /// Whether an initial LAC context was established. + bool yy_lac_established_; + + + /// Push a new state on the stack. + /// \param m a debug message to display + /// if null, no trace is output. + /// \param sym the symbol + /// \warning the contents of \a s.value is stolen. + void yypush_ (const char* m, YY_MOVE_REF (stack_symbol_type) sym); + + /// Push a new look ahead token on the state on the stack. + /// \param m a debug message to display + /// if null, no trace is output. + /// \param s the state + /// \param sym the symbol (for its value and location). + /// \warning the contents of \a sym.value is stolen. + void yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym); + + /// Pop \a n symbols from the stack. + void yypop_ (int n = 1) YY_NOEXCEPT; + + /// Constants. + enum + { + yylast_ = 53, ///< Last index in yytable_. + yynnts_ = 7, ///< Number of nonterminal symbols. + yyfinal_ = 12 ///< Termination state number. + }; + + + // User arguments. + ASTDriver& drv; + + }; + + inline + parser::symbol_kind_type + parser::yytranslate_ (int t) YY_NOEXCEPT + { + return static_cast (t); + } + + // basic_symbol. + template + parser::basic_symbol::basic_symbol (const basic_symbol& that) + : Base (that) + , value () + , location (that.location) + { + switch (this->kind ()) + { + case symbol_kind::S_INT: // "number" + case symbol_kind::S_list: // list + value.copy< int > (YY_MOVE (that.value)); + break; + + case symbol_kind::S_OPERATOR: // OPERATOR + case symbol_kind::S_IDENTIFIER: // "identifier" + case symbol_kind::S_VARNAME: // VARNAME + value.copy< std::string > (YY_MOVE (that.value)); + break; + + case symbol_kind::S_index: // index + value.copy< std::tuple > (YY_MOVE (that.value)); + break; + + case symbol_kind::S_indices_list: // indices_list + value.copy< std::vector> > (YY_MOVE (that.value)); + break; + + default: + break; + } + + } + + + + + template + parser::symbol_kind_type + parser::basic_symbol::type_get () const YY_NOEXCEPT + { + return this->kind (); + } + + + template + bool + parser::basic_symbol::empty () const YY_NOEXCEPT + { + return this->kind () == symbol_kind::S_YYEMPTY; + } + + template + void + parser::basic_symbol::move (basic_symbol& s) + { + super_type::move (s); + switch (this->kind ()) + { + case symbol_kind::S_INT: // "number" + case symbol_kind::S_list: // list + value.move< int > (YY_MOVE (s.value)); + break; + + case symbol_kind::S_OPERATOR: // OPERATOR + case symbol_kind::S_IDENTIFIER: // "identifier" + case symbol_kind::S_VARNAME: // VARNAME + value.move< std::string > (YY_MOVE (s.value)); + break; + + case symbol_kind::S_index: // index + value.move< std::tuple > (YY_MOVE (s.value)); + break; + + case symbol_kind::S_indices_list: // indices_list + value.move< std::vector> > (YY_MOVE (s.value)); + break; + + default: + break; + } + + location = YY_MOVE (s.location); + } + + // by_kind. + inline + parser::by_kind::by_kind () YY_NOEXCEPT + : kind_ (symbol_kind::S_YYEMPTY) + {} + +#if 201103L <= YY_CPLUSPLUS + inline + parser::by_kind::by_kind (by_kind&& that) YY_NOEXCEPT + : kind_ (that.kind_) + { + that.clear (); + } +#endif + + inline + parser::by_kind::by_kind (const by_kind& that) YY_NOEXCEPT + : kind_ (that.kind_) + {} + + inline + parser::by_kind::by_kind (token_kind_type t) YY_NOEXCEPT + : kind_ (yytranslate_ (t)) + {} + + + + inline + void + parser::by_kind::clear () YY_NOEXCEPT + { + kind_ = symbol_kind::S_YYEMPTY; + } + + inline + void + parser::by_kind::move (by_kind& that) + { + kind_ = that.kind_; + that.clear (); + } + + inline + parser::symbol_kind_type + parser::by_kind::kind () const YY_NOEXCEPT + { + return kind_; + } + + + inline + parser::symbol_kind_type + parser::by_kind::type_get () const YY_NOEXCEPT + { + return this->kind (); + } + + +#line 6 "../parser.y" +} } // adios2::detail +#line 1605 "parser.h" + + + + +#endif // !YY_YY_PARSER_H_INCLUDED diff --git a/source/adios2/toolkit/format/bp5/BP5Deserializer.cpp b/source/adios2/toolkit/format/bp5/BP5Deserializer.cpp index 0e7574a17c..9c1a127408 100644 --- a/source/adios2/toolkit/format/bp5/BP5Deserializer.cpp +++ b/source/adios2/toolkit/format/bp5/BP5Deserializer.cpp @@ -1994,6 +1994,8 @@ BP5Deserializer::~BP5Deserializer() m_Engine->m_IO.RemoveVariable(VarRec.second->VarName); free(VarRec.second->VarName); + if (VarRec.second->ExprStr) + free(VarRec.second->ExprStr); if (VarRec.second->Operator) free(VarRec.second->Operator); if (VarRec.second->Def) diff --git a/testing/adios2/bindings/fortran/CMakeLists.txt b/testing/adios2/bindings/fortran/CMakeLists.txt index c026628343..f1664f3d1f 100644 --- a/testing/adios2/bindings/fortran/CMakeLists.txt +++ b/testing/adios2/bindings/fortran/CMakeLists.txt @@ -15,6 +15,9 @@ macro(fortran_add_test_helper testname mpi) add_executable(${tgt} Test${testname}.F90) set_target_properties(${tgt} PROPERTIES LINKER_LANGUAGE Fortran) target_link_libraries(${tgt} adios2::fortran) + if (ADIOS2_HAVE_Derived_Variable) + target_compile_definitions(${tgt} PRIVATE -DADIOS2_HAVE_Derived_Variable=1) + endif() add_test( NAME ${pfx}${testname}.Serial COMMAND ${tgt} @@ -26,6 +29,9 @@ macro(fortran_add_test_helper testname mpi) add_executable(${tgt} Test${testname}.F90) set_target_properties(${tgt} PROPERTIES LINKER_LANGUAGE Fortran) target_link_libraries(${tgt} adios2::fortran_mpi MPI::MPI_Fortran) + if (ADIOS2_HAVE_Derived_Variable) + target_compile_definitions(${tgt} PRIVATE -DADIOS2_HAVE_Derived_Variable=1) + endif() add_test( NAME ${pfx}${testname}.MPI COMMAND ${MPIEXEC_COMMAND} $ diff --git a/testing/adios2/bindings/fortran/TestBPWriteTypes.F90 b/testing/adios2/bindings/fortran/TestBPWriteTypes.F90 index 7cb02991e0..2145baedf8 100644 --- a/testing/adios2/bindings/fortran/TestBPWriteTypes.F90 +++ b/testing/adios2/bindings/fortran/TestBPWriteTypes.F90 @@ -51,14 +51,26 @@ program TestBPWriteTypes start_dims(1) = irank*inx count_dims(1) = inx - if( adios%valid .eqv. .true. ) stop 'Invalid adios default' - if( ioWrite%valid .eqv. .true. ) stop 'Invalid io default' + if( adios%valid .eqv. .true. ) then + write(*,*) 'Invalid adios default' + stop 1 + end if + if( ioWrite%valid .eqv. .true. ) then + write(*,*) 'Invalid io default' + stop 1 + end if do i=1,12 - if( variables(i)%valid .eqv. .true. ) stop 'Invalid variables default' + if( variables(i)%valid .eqv. .true. ) then + write(*,*) 'Invalid variables default' + stop 1 + end if end do - if( bpWriter%valid .eqv. .true. ) stop 'Invalid engine default' + if( bpWriter%valid .eqv. .true. ) then + write(*,*) 'Invalid engine default' + stop 1 + end if ! Create adios handler passing the communicator and error flag @@ -67,38 +79,62 @@ program TestBPWriteTypes #else call adios2_init(adios, ierr) #endif - if( adios%valid .eqv. .false. ) stop 'Invalid adios2_init' + if( adios%valid .eqv. .false. ) then + write(*,*) 'Invalid adios2_init' + stop 1 + end if !!!!!!!!!!!!!!!!!!!!!!!! WRITER !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! Declare an IO process configuration inside adios call adios2_declare_io(ioWrite, adios, "ioWrite", ierr) - if( ioWrite%valid .eqv. .false. ) stop 'Invalid adios2_declare_io' + if( ioWrite%valid .eqv. .false. ) then + write(*,*) 'Invalid adios2_declare_io' + stop 1 + end if call adios2_at_io(ioWrite, adios, "ioWrite", ierr) - if( ioWrite%valid .eqv. .false. ) stop 'Invalid adios2_at_io' + if( ioWrite%valid .eqv. .false. ) then + write(*,*) 'Invalid adios2_at_io' + stop 1 + end if call adios2_in_config_file(result, ioWrite, ierr) - if( result .eqv. .true. ) stop 'Invalid ioWrite adios2_in_config_file' + if( result .eqv. .true. ) then + write(*,*) 'Invalid ioWrite adios2_in_config_file' + stop 1 + end if call adios2_set_engine(ioWrite, 'File', ierr) call adios2_set_parameter(ioWrite, 'ProfileUnits', 'Microseconds', ierr) call adios2_get_parameter(param_value, ioWrite, 'ProfileUnits', ierr) - if( param_value /= "Microseconds") stop 'Failed adios2_get_parameter ProfileUnits' + if( param_value /= "Microseconds") then + write(*,*) 'Failed adios2_get_parameter ProfileUnits' + stop 1 + end if call adios2_set_parameters(ioWrite, 'Threads=2, CollectiveMetadata = OFF', ierr) call adios2_get_parameter(param_value, ioWrite, 'Threads', ierr) - if( param_value /= "2") stop 'Failed adios2_get_parameter Threads' + if( param_value /= "2") then + write(*,*) 'Failed adios2_get_parameter Threads' + stop 1 + end if call adios2_get_parameter(param_value, ioWrite, 'CollectiveMetadata', ierr) - if( param_value /= "OFF") stop 'Failed adios2_get_parameter CollectiveMetadata' + if( param_value /= "OFF") then + write(*,*) 'Failed adios2_get_parameter CollectiveMetadata' + stop 1 + end if ! set back the default to make sure writing/reading test works call adios2_clear_parameters(ioWrite, ierr) call adios2_get_parameter(param_value, ioWrite, 'CollectiveMetadata', ierr) - if( param_value /= "") stop 'Still Could retrieve parameter CollectiveMetadata after clearing all parameters' + if( param_value /= "") then + write(*,*) 'Still Could retrieve parameter CollectiveMetadata after clearing all parameters' + stop 1 + end if deallocate(param_value) @@ -166,41 +202,71 @@ program TestBPWriteTypes ! derived variable call adios2_define_derived_variable(derived_variable, ioWrite, "derived/magnitude_of_var_R64", & - "x:var_R64 y:var_R64 z:var_R64 magnitude(x,y,z)", adios2_derived_var_type_metadata_only, ierr) - + "x=var_R64 y=var_R64 z=var_R64 magnitude(x,y,z)", adios2_derived_var_type_metadata_only, ierr) +#if ADIOS2_HAVE_Derived_Variable +#define TOTAL_VAR_COUNT 15 +#else +#define TOTAL_VAR_COUNT 14 +#endif do i=1,13 - if( variables(i)%valid .eqv. .false. ) stop 'Invalid adios2_define_variable' + if( variables(i)%valid .eqv. .false. ) then + write(*,*) 'Invalid adios2_define_variable' + stop 1 + end if end do ! Testing adios2_variable_name for just two cases call adios2_variable_name(varName, variables(1), ierr) - if (varName /= 'var_I8') stop 'Invalid adios2_variable_name' + if (varName /= 'var_I8') then + write(*,*) 'Invalid adios2_variable_name' + stop 1 + end if call adios2_variable_name(varName, variables(2), ierr) - if (varName /= 'var_I16') stop 'Invalid adios2_variable_name' + if (varName /= 'var_I16') then + write(*,*) 'Invalid adios2_variable_name' + stop 1 + end if deallocate(varName) ! Open myVector_f.bp in write mode, this launches an engine - if( ioWrite%valid .eqv. .false. ) stop 'Invalid adios2_io' - if( bpWriter%valid .eqv. .true. ) stop 'Invalid adios2_engine pre-open' + if( ioWrite%valid .eqv. .false. ) then + write(*,*) 'Invalid adios2_io' + stop 1 + end if + if( bpWriter%valid .eqv. .true. ) then + write(*,*) 'Invalid adios2_engine pre-open' + stop 1 + end if call adios2_open(bpWriter, ioWrite, "ftypes.bp", adios2_mode_write, ierr) - if( bpWriter%valid .eqv. .false. ) stop 'Invalid adios2_engine post-open' - if( TRIM(bpWriter%name) /= "ftypes.bp") stop 'Invalid adios2_engine name' + if( bpWriter%valid .eqv. .false. ) then + write(*,*) 'Invalid adios2_engine post-open' + stop 1 + end if + if( TRIM(bpWriter%name) /= "ftypes.bp") then + write(*,*) 'Invalid adios2_engine name' + stop 1 + end if if( TRIM(bpWriter%type) /= 'BP5Writer') then write(*,*) 'Engine Type ', TRIM(bpWriter%type) - stop 'Invalid adios2_engine type' + write(*,*) 'Invalid adios2_engine type' + stop 1 end if call adios2_io_engine_type(engineType, ioWrite, ierr) if( engineType /= 'File') then ! FIXME, different from the above! write(*,*) 'Engine Type ', engineType - stop 'Invalid type from adios2_engine_type' + write(*,*) 'Invalid type from adios2_engine_type' + stop 1 end if - if( bpWriter%mode /= adios2_mode_write) stop 'Invalid adios2_engine mode' + if( bpWriter%mode /= adios2_mode_write) then + write(*,*) 'Invalid adios2_engine mode' + stop 1 + end if ! Put array contents to bp buffer, based on var1 metadata do i = 1, 3 @@ -232,7 +298,10 @@ program TestBPWriteTypes ! Closes engine1 and deallocates it, becomes unreachable call adios2_close(bpWriter, ierr) - if( bpWriter%valid .eqv. .true. ) stop 'Invalid adios2_close' + if( bpWriter%valid .eqv. .true. ) then + write(*,*) 'Invalid adios2_close' + stop 1 + end if !!!!!!!!!!!!!!!!!!!!!!!! READER !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! Declare io reader @@ -241,80 +310,179 @@ program TestBPWriteTypes call adios2_open(bpReader, ioRead, "ftypes.bp", adios2_mode_readRandomAccess, ierr) call adios2_steps(nsteps, bpReader, ierr) - if(nsteps /= 3) stop 'ftypes.bp must have 3 steps' + if(nsteps /= 3) then + write(*,*) 'ftypes.bp must have 3 steps' + stop 1 + end if call adios2_available_variables(ioRead, namestruct, ierr) - if (ierr /= 0) stop 'adios2_available_variables returned with error' - if (.not.namestruct%valid) stop 'adios2_available_variables returned invalid struct' + if (ierr /= 0) then + write(*,*) 'adios2_available_variables returned with error' + stop 1 + end if + if (.not.namestruct%valid) then + write(*,*) 'adios2_available_variables returned invalid struct' + stop 1 + end if write(*,*) 'Number of variables = ', namestruct%count write(*,*) 'Max name length = ', namestruct%max_name_len - if (namestruct%count /= 14) stop 'adios2_available_variables returned not the expected 14' + if (namestruct%count /= TOTAL_VAR_COUNT) then + write(*,*) 'adios2_available_variables returned not the expected 14' + stop 1 + end if allocate(varnamelist(namestruct%count)) call adios2_retrieve_names(namestruct, varnamelist, ierr) - if (ierr /= 0) stop 'adios2_retrieve_names returned with error' + if (ierr /= 0) then + write(*,*) 'adios2_retrieve_names returned with error' + stop 1 + end if do i=1,namestruct%count write(*,'("Var[",i2,"] = ",a12)') i, varnamelist(i) end do deallocate(varnamelist) - if (namestruct%f2c /= 0_8) stop 'namestruct f2c pointer is not null after adios2_retrieve_names()' - if (namestruct%valid) stop 'namestruct is not invalidated after adios2_retrieve_names()' + if (namestruct%f2c /= 0_8) then + write(*,*) 'namestruct f2c pointer is not null after adios2_retrieve_names()' + stop 1 + end if + if (namestruct%valid) then + write(*,*) 'namestruct is not invalidated after adios2_retrieve_names()' + stop 1 + end if call adios2_inquire_variable(variables(1), ioRead, "var_I8", ierr) - if (variables(1)%name /= 'var_I8') stop 'var_I8 not recognized' - if (variables(1)%type /= adios2_type_integer1) stop 'var_I8 type not recognized' + if (variables(1)%name /= 'var_I8') then + write(*,*) 'var_I8 not recognized' + stop 1 + end if + if (variables(1)%type /= adios2_type_integer1) then + write(*,*) 'var_I8 type not recognized' + stop 1 + end if call adios2_variable_shape(shape_in, ndims, variables(1), ierr) - if (ndims /= 1) stop 'var_I8 ndims is not 1' - if (shape_in(1) /= isize*inx) stop 'var_I8 shape_in read failed' + if (ndims /= 1) then + write(*,*) 'var_I8 ndims is not 1' + stop 1 + end if + if (shape_in(1) /= isize*inx) then + write(*,*) 'var_I8 shape_in read failed' + stop 1 + end if call adios2_inquire_variable(variables(2), ioRead, "var_I16", ierr) - if (variables(2)%name /= 'var_I16') stop 'var_I16 not recognized' - if (variables(2)%type /= adios2_type_integer2) stop 'var_I16 type not recognized' + if (variables(2)%name /= 'var_I16') then + write(*,*) 'var_I16 not recognized' + stop 1 + end if + if (variables(2)%type /= adios2_type_integer2) then + write(*,*) 'var_I16 type not recognized' + stop 1 + end if call adios2_variable_shape(shape_in, ndims, variables(2), ierr) - if (ndims /= 1) stop 'var_I16 ndims is not 1' - if (shape_in(1) /= isize*inx) stop 'var_I16 shape_in read failed' + if (ndims /= 1) then + write(*,*) 'var_I16 ndims is not 1' + stop 1 + end if + if (shape_in(1) /= isize*inx) then + write(*,*) 'var_I16 shape_in read failed' + stop 1 + end if call adios2_inquire_variable(variables(3), ioRead, "var_I32", ierr) - if (variables(3)%name /= 'var_I32') stop 'var_I32 not recognized' - if (variables(3)%type /= adios2_type_integer4) stop 'var_I32 type not recognized' + if (variables(3)%name /= 'var_I32') then + write(*,*) 'var_I32 not recognized' + stop 1 + end if + if (variables(3)%type /= adios2_type_integer4) then + write(*,*) 'var_I32 type not recognized' + stop 1 + end if call adios2_variable_shape(shape_in, ndims, variables(3), ierr) - if (ndims /= 1) stop 'var_I32 ndims is not 1' - if (shape_in(1) /= isize*inx) stop 'var_I32 shape_in read failed' + if (ndims /= 1) then + write(*,*) 'var_I32 ndims is not 1' + stop 1 + end if + if (shape_in(1) /= isize*inx) then + write(*,*) 'var_I32 shape_in read failed' + stop 1 + end if call adios2_inquire_variable(variables(4), ioRead, "var_I64", ierr) - if (variables(4)%name /= 'var_I64') stop 'var_I64 not recognized' - if (variables(4)%type /= adios2_type_integer8) stop 'var_I64 type not recognized' + if (variables(4)%name /= 'var_I64') then + write(*,*) 'var_I64 not recognized' + stop 1 + end if + if (variables(4)%type /= adios2_type_integer8) then + write(*,*) 'var_I64 type not recognized' + stop 1 + end if call adios2_variable_shape(shape_in, ndims, variables(4), ierr) - if (ndims /= 1) stop 'var_I64 ndims is not 1' - if (shape_in(1) /= isize*inx) stop 'var_I64 shape_in read failed' + if (ndims /= 1) then + write(*,*) 'var_I64 ndims is not 1' + stop 1 + end if + if (shape_in(1) /= isize*inx) then + write(*,*) 'var_I64 shape_in read failed' + stop 1 + end if call adios2_inquire_variable(variables(5), ioRead, "var_R32", ierr) - if (variables(5)%name /= 'var_R32') stop 'var_R32 not recognized' - if (variables(5)%type /= adios2_type_real) stop 'var_R32 type not recognized' + if (variables(5)%name /= 'var_R32') then + write(*,*) 'var_R32 not recognized' + stop 1 + end if + if (variables(5)%type /= adios2_type_real) then + write(*,*) 'var_R32 type not recognized' + stop 1 + end if call adios2_variable_shape(shape_in, ndims, variables(5), ierr) - if (ndims /= 1) stop 'var_R32 ndims is not 1' - if (shape_in(1) /= isize*inx) stop 'var_R32 shape_in read failed' + if (ndims /= 1) then + write(*,*) 'var_R32 ndims is not 1' + stop 1 + end if + if (shape_in(1) /= isize*inx) then + write(*,*) 'var_R32 shape_in read failed' + stop 1 + end if call adios2_inquire_variable(variables(6), ioRead, "var_R64", ierr) - if (variables(6)%name /= 'var_R64') stop 'var_R64 not recognized' - if (variables(6)%type /= adios2_type_dp) stop 'var_R64 type not recognized' + if (variables(6)%name /= 'var_R64') then + write(*,*) 'var_R64 not recognized' + stop 1 + end if + if (variables(6)%type /= adios2_type_dp) then + write(*,*) 'var_R64 type not recognized' + stop 1 + end if call adios2_variable_shape(shape_in, ndims, variables(6), ierr) - if (ndims /= 1) stop 'var_R64 ndims is not 1' - if (shape_in(1) /= isize*inx) stop 'var_R64 shape_in read failed' + if (ndims /= 1) then + write(*,*) 'var_R64 ndims is not 1' + stop 1 + end if + if (shape_in(1) /= isize*inx) then + write(*,*) 'var_R64 shape_in read failed' + stop 1 + end if call adios2_inquire_variable(variables(13), ioRead, "gvar_Str", ierr) call adios2_get(bpReader, variables(13), inString, ierr) call adios2_perform_gets(bpReader, ierr) - if( inString /= data_Strings(1) ) stop 'gvar_Str read failed' + if( inString /= data_Strings(1) ) then + write(*,*) 'gvar_Str read failed' + stop 1 + end if call adios2_inquire_variable(variables(14), ioRead, "lvar_i32", ierr) allocate(inRanks(isize)) call adios2_get(bpReader, variables(14), inRanks, ierr) call adios2_perform_gets(bpReader, ierr) - if( inRanks(irank+1) /= irank ) stop 'lvar_i32 read failed' + if( inRanks(irank+1) /= irank ) then + write(*,*) 'lvar_i32 read failed' + stop 1 + end if deallocate(inRanks) call adios2_close(bpReader, ierr) diff --git a/testing/adios2/derived/TestBPDerivedCorrectness.cpp b/testing/adios2/derived/TestBPDerivedCorrectness.cpp index 002015b843..886b942db3 100644 --- a/testing/adios2/derived/TestBPDerivedCorrectness.cpp +++ b/testing/adios2/derived/TestBPDerivedCorrectness.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -36,25 +37,21 @@ TEST(DerivedCorrectness, AddCorrectnessTest) std::vector varname = {"sim1/Ux", "sim1/Uy", "sim1/Uz"}; std::string derivedname = "derived/addU"; - std::cout << "Define Variable " << varname[0] << std::endl; auto Ux = bpOut.DefineVariable(varname[0], {Nx, Ny, Nz}, {0, 0, 0}, {Nx, Ny, Nz}); - std::cout << "Define Variable " << varname[1] << std::endl; auto Uy = bpOut.DefineVariable(varname[1], {Nx, Ny, Nz}, {0, 0, 0}, {Nx, Ny, Nz}); - std::cout << "Define Variable " << varname[2] << std::endl; auto Uz = bpOut.DefineVariable(varname[2], {Nx, Ny, Nz}, {0, 0, 0}, {Nx, Ny, Nz}); - std::cout << "Define Derived Variable " << derivedname << std::endl; // clang-format off - auto addU = bpOut.DefineDerivedVariable(derivedname, - "x:" + varname[0] + " \n" - "y:" + varname[1] + " \n" - "z:" + varname[2] + " \n" - "x+y+z", - adios2::DerivedVarType::StoreData); + bpOut.DefineDerivedVariable(derivedname, + "x =" + varname[0] + " \n" + "y =" + varname[1] + " \n" + "z =" + varname[2] + " \n" + "x+y+z", + adios2::DerivedVarType::StoreData); // clang-format on std::string filename = "expAdd.bp"; adios2::Engine bpFileWriter = bpOut.Open(filename, adios2::Mode::Write); - for (int i = 0; i < steps; i++) + for (size_t i = 0; i < steps; i++) { bpFileWriter.BeginStep(); bpFileWriter.Put(Ux, simArray1.data()); @@ -73,8 +70,8 @@ TEST(DerivedCorrectness, AddCorrectnessTest) std::vector readAdd; float calcA; - float epsilon = 0.01; - for (int i = 0; i < steps; i++) + float epsilon = (float)0.01; + for (size_t i = 0; i < steps; i++) { bpFileReader.BeginStep(); bpFileReader.Get(varname[0], readUx); @@ -119,17 +116,17 @@ TEST(DerivedCorrectness, MagCorrectnessTest) auto Uy = bpOut.DefineVariable(varname[1], {Nx, Ny, Nz}, {0, 0, 0}, {Nx, Ny, Nz}); auto Uz = bpOut.DefineVariable(varname[2], {Nx, Ny, Nz}, {0, 0, 0}, {Nx, Ny, Nz}); // clang-format off - auto magU = bpOut.DefineDerivedVariable(derivedname, - "x:" + varname[0] + " \n" - "y:" + varname[1] + " \n" - "z:" + varname[2] + " \n" - "magnitude(x,y,z)", - adios2::DerivedVarType::StoreData); + bpOut.DefineDerivedVariable(derivedname, + "x =" + varname[0] + " \n" + "y =" + varname[1] + " \n" + "z =" + varname[2] + " \n" + "magnitude(x,y,z)", + adios2::DerivedVarType::StoreData); // clang-format on std::string filename = "expMagnitude.bp"; adios2::Engine bpFileWriter = bpOut.Open(filename, adios2::Mode::Write); - for (int i = 0; i < steps; i++) + for (size_t i = 0; i < steps; i++) { bpFileWriter.BeginStep(); bpFileWriter.Put(Ux, simArray1.data()); @@ -148,8 +145,8 @@ TEST(DerivedCorrectness, MagCorrectnessTest) std::vector readMag; float calcM; - float epsilon = 0.01; - for (int i = 0; i < steps; i++) + float epsilon = (float)0.01; + for (size_t i = 0; i < steps; i++) { bpFileReader.BeginStep(); auto varx = bpIn.InquireVariable(varname[0]); @@ -165,7 +162,7 @@ TEST(DerivedCorrectness, MagCorrectnessTest) for (size_t ind = 0; ind < Nx * Ny * Nz; ++ind) { - calcM = sqrt(pow(readUx[ind], 2) + pow(readUy[ind], 2) + pow(readUz[ind], 2)); + calcM = (float)sqrt(pow(readUx[ind], 2) + pow(readUy[ind], 2) + pow(readUz[ind], 2)); EXPECT_TRUE(fabs(calcM - readMag[ind]) < epsilon); } }