Mercurial > ~dholland > hg > ag > index.cgi
view anagram/agcore/tree.cpp @ 14:a02e9434072e
Fix friend declaration for gcc10.
XXX: did not check it against the IBM compiler, might end up needing
XXX: to be conditional.
author | David A. Holland |
---|---|
date | Tue, 31 May 2022 00:59:42 -0400 |
parents | 607e3be6bad8 |
children |
line wrap: on
line source
/* * AnaGram, A System for Syntax Directed Programming * Copyright 1993-2002 Parsifal Software. All Rights Reserved. * See the file COPYING for license and usage terms. * * tree.cpp */ #include "assert.h" #include "csexp.h" #include "tree.h" //#define INCLUDE_LOGGING #include "log.h" int parse_tree_map::operator < (const parse_tree_map &t) const { LOGSECTION_OFF("parse_tree_map::operator <"); LOGV(expression != 0 ? expression->asString() : AgString()); LOGV(t.expression != 0 ? t.expression->asString() : AgString()); if (expression && t.expression) { return *expression < *t.expression; } if (expression == 0) { return t.expression != 0; } return 0; } ParseTree::ParseTree(unsigned x) : KeyedObjectRegister<parse_tree_map>(x) {} ParseTree::ParseTree(const ParseTree &t) : KeyedObjectRegister<parse_tree_map>(t) {} void ParseTree::operator = (const ParseTree &t) { KeyedObjectRegister<parse_tree_map>::operator = (t); } ParseTree::ParseTree(CharSetExpression *x) : KeyedObjectRegister<parse_tree_map>(parse_tree_map(x)) { LOGSECTION("ParseTree::ParseTree"); LOGV(index) LCV(x == 0 ? AgString() : x->asString()); LOGV((int) x) LCV((int) descriptor->expression); if (descriptor->expression != x) { delete x; } } parse_tree_map &ParseTree::Map::operator [] (unsigned x) { assert(x < ParseTree::descriptorList.size()); return ParseTree::descriptorList[x]; } void ParseTree::reset() { LOGSECTION("ParseTree::reset"); int n = descriptorList.size(); while (n-- > 0) { delete descriptorList[n].expression; } KeyedObjectRegister<parse_tree_map>::reset(); //descriptorList.push(parse_tree_map()); ParseTree parseTree((CharSetExpression *) 0); } parse_tree_map::parse_tree_map() : expression(0), char_set(0) { // Nothing to do } parse_tree_map::parse_tree_map(CharSetExpression *x) : expression(x), char_set(0) { LOGSECTION("parse_tree_map::parse_tree_map"); LOGV((int) this) LCV((int) x); } ParseTree::Map map_parse_tree;