diff anagram/agcore/symbol.cpp @ 0:13d2b8934445

Import AnaGram (near-)release tree into Mercurial.
author David A. Holland
date Sat, 22 Dec 2007 17:52:45 -0500
parents
children 607e3be6bad8
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/anagram/agcore/symbol.cpp	Sat Dec 22 17:52:45 2007 -0500
@@ -0,0 +1,83 @@
+/*
+ * 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;
+}