ExpressionType GetType() const { if (IsTensor()) return ExpressionType::TENSOR; else if (IsScalar()) return ExpressionType::SCALAR; else if (IsIndices()) return ExpressionType::INDICES; else if (IsBoolean()) return ExpressionType::BOOLEAN; else if (IsSubstitution()) return ExpressionType::SUBSTITUTION; else if (IsVoid()) return ExpressionType::VOID_TYPE; return ExpressionType::UNKNOWN; }
void PrintListGeneric(VyParseTree* tree, char oDelim, char cDelim){ printf("%c", oDelim); /* Print each element recursively */ int i; for(i = 0; i < ListTreeSize(tree); i++){ VyParseTree* next = GetListData(tree,i); if(IsQuote(next)){ printf("'"); PrintParseTree(GetListData(next, 1)); } else if(IsSubstitution(next)){ if(IsSplicingSubstitution(next)){ printf("$@"); }else{ printf("$"); } PrintParseTree(GetListData(next, 1)); } else if(next->type == TREE_LIST){ VyParseTree* first = GetListData(next, 0); if(first->type == TREE_IDENT && StrEquals(GetStrData(first), "infix")){ PrintListGeneric(GetListData(next, 1), '{','}'); } else if(first->type == TREE_IDENT && StrEquals(GetStrData(first), "quote-substitutions")){ PrintListGeneric(GetListData(next, 1), '[',']'); }else{ PrintParseTree(next); } } else{ PrintParseTree(next); } } /* If it wasn't an empty list, remove the extra space generated by the item inside */ if(ListTreeSize(tree) > 0){ printf("\b"); } printf("%c ", cDelim); }