bool ArraysASTPlugin::hasUnambiguousPackageInfixGrammar(const ASTNode *child) const { ASTBase* function = const_cast<ASTBase*>(getParentASTObject()); if (function == NULL) return false; if (function->getType() != AST_ORIGINATES_IN_PACKAGE) return false; if (function->getPackageName() != "arrays") return false; // cast the function to an ASTNode ASTNode* newAST = dynamic_cast<ASTNode*>(function); if (newAST == NULL) { return false; } const ArraysASTPlugin* aap = static_cast<const ArraysASTPlugin*>(function->getPlugin("arrays")); switch(aap->getASTType()) { case AST_LINEAR_ALGEBRA_SELECTOR: if (newAST->getNumChildren() == 0) return true; if (newAST->getChild(0) == child) return false; //The *first* child of the selector needs parentheses in some situations! return true; //All other children are separated by commas, and thus don't need parentheses. case AST_LINEAR_ALGEBRA_VECTOR_CONSTRUCTOR: #if (0) case AST_LINEAR_ALGEBRA_MATRIX_CONSTRUCTOR: case AST_LINEAR_ALGEBRA_DETERMINANT: case AST_LINEAR_ALGEBRA_TRANSPOSE: case AST_LINEAR_ALGEBRA_VECTOR_PRODUCT: case AST_LINEAR_ALGEBRA_SCALAR_PRODUCT: case AST_LINEAR_ALGEBRA_OUTER_PRODUCT: case AST_LINEAR_ALGEBRA_MATRIXROW_CONSTRUCTOR: #endif case AST_QUALIFIER_CONDITION: case AST_LOGICAL_EXISTS: case AST_LOGICAL_FORALL: case AST_QUALIFIER_LOWLIMIT: case AST_STATISTICS_MEAN: case AST_STATISTICS_MEDIAN: case AST_STATISTICS_MODE: case AST_STATISTICS_MOMENT: case AST_QUALIFIER_MOMENTABOUT: case AST_SERIES_PRODUCT: case AST_STATISTICS_SDEV: case AST_SERIES_SUM: case AST_QUALIFIER_UPLIMIT: case AST_STATISTICS_VARIANCE: return true; //Everything is either a function or has unambiguous syntax. case AST_ARRAYS_UNKNOWN: return false; } return false; }
bool MultiASTPlugin::hasAttributesSet() const { bool hasAttributes = false; if (isSetSpeciesReference() == true) { return true; } else if (isSetRepresentationType() == true) { return true; } else if (mParent != NULL) { unsigned int i = 0; ASTNode* node = dynamic_cast<ASTNode*>(mParent); size_t numChildren; GET_NUM_CHILDREN(numChildren,mParent); while (hasAttributes == false && i < numChildren) { ASTBase* ast = NULL; GET_NTH_CHILD(ast, i, mParent); if (ast != NULL) { MultiASTPlugin* mp = static_cast<MultiASTPlugin*>(ast->getPlugin("multi")); if (mp != NULL) { hasAttributes = mp->hasAttributesSet(); } } i++; } } return hasAttributes; }