view anagram/agcore/symbol.cpp @ 12:aab9ff6af791

Strengthen the build hack for non-DOS targets.
author David A. Holland
date Tue, 31 May 2022 00:58: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.
 *
 * 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::operator = (const Symbol &t) {
  KeyedObjectRegister<SymbolDescriptor>::operator = (t);
}

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;
}