view anagram/agcore/symbol.cpp @ 5:7661c1604e49

Add additional operator delete calls gcc 10 asked for.
author David A. Holland
date Mon, 30 May 2022 23:32:56 -0400
parents 13d2b8934445
children 607e3be6bad8
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.
 *
 * symbol.cpp
 */

#include "symbol.h"
#include "stacks.h"

//#define INCLUDE_LOGGING
#include "log.h"


Symbol::Symbol(unsigned x) : KeyedObjectRegister<SymbolDescriptor>(x) {}
Symbol::Symbol(const Symbol &t) : KeyedObjectRegister<SymbolDescriptor>(t) {}

Symbol::Symbol(const char *x)
  : KeyedObjectRegister<SymbolDescriptor>(SymbolDescriptor(x))
{
  // Nothing to do
}

void Symbol::reset() {
  LOGSECTION("Symbol::reset");
  KeyedObjectRegister<SymbolDescriptor>::reset();
  //descriptorList.push(SymbolDescriptor());
  Symbol("");
  LOGV(descriptorList.size()) LCV(Symbol()->string);
}

Symbol Symbol::sorted(int x) {
  LOGSECTION("Symbol::sorted");
  LOGV(x);
  Symbol symbol = tree[x];
  LOGV(symbol) LCV(symbol->string);
  return symbol;
}

Symbol Symbol::create() {
  LOGSECTION("Symbol::create");
  tss();
  LOGV(string_base);
  Symbol symbol(string_base);
  rcs();
  LOGV(symbol);
  return symbol;
}

Symbol add_string_dict(const char *s, Symbol::Dict &d) {
  return d.add_string(s);
}

Symbol::Map map_token_name;
Symbol::Dict tkn_dict;

SymbolDescriptor &Symbol::Map::operator [] (unsigned x) {
  LOGSECTION("Symbol::Map::operator []");
  LOGV(x) LCV(descriptorList.size());
  assert(x < Symbol::descriptorList.size());
  return Symbol::descriptorList[x];
}

Symbol Symbol::Dict::add_string(const char *s) {
  return Symbol(s);
}

SymbolDescriptor::SymbolDescriptor()
  : token_list_id(0)
{
  // Nothing to do
}

SymbolDescriptor::SymbolDescriptor(const char *s)
  : string(s), token_list_id(0)
{
  // Nothing to do
}

int SymbolDescriptor::operator < (const SymbolDescriptor &d) const {
  return string < d.string;
}