view anagram/guisupport/anom.cpp @ 21:1c9dac05d040

Add lint-style FALLTHROUGH annotations to fallthrough cases. (in the parse engine and thus the output code) Document this, because the old output causes warnings with gcc10.
author David A. Holland
date Mon, 13 Jun 2022 00:04:38 -0400
parents 13d2b8934445
children
line wrap: on
line source

/*
 * AnaGram, A System for Syntax Directed Programming
 * Copyright 1993-1999 Parsifal Software. All Rights Reserved.
 * See the file COPYING for license and usage terms.
 *
 * anom.cpp - Anomaly diagnosis module
 */

#include "anom.h"
#include "cd.h"
#include "conflictdc.h"
#include "conflicttrc.h"
#include "data.h"
#include "dc.h"
#include "nckwtr.h"
#include "rule.h"
#include "stacks.h"
#include "tracedc.h"
#include "ut.h"
#include "wm1.h"
#include "ws.h"

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


static void find_anomaly(int sn, int tn, int fn) {
  LOGSECTION("find_anomaly");
  analyze_conflict(sn, tn, fn, 1);
}

static int anomaly_table_tabs[] = {7,13,15,0};

anomaly_table_dc::anomaly_table_dc(void)
  : dc("Keyword Anomalies")
{
  LOGSECTION("anomaly_table_dc::anomaly_table_dc");
  tab_stops = anomaly_table_tabs;
  des->d_size.y = 2*key_mess->nt;
  //getWidth();
  //des->c_size = cint(des->d_size.x,1);
  //resize_window();
}

dc_ref anomaly_table_dc::anomaly_trace(unsigned ln) {
  LOGSECTION("anomaly_table_dc::anomaly_trace");
  int sn, tn, fn, rs;
  dc_ref new_window;
  tsd *stack;

  xtx(key_mess, ln/2, &sn, &tn, &fn, &rs);
  find_anomaly(sn, tn, fn);
  stack = make_stored_trace(&new_conflict_stack[0],
			    new_conflict_stack_depth, conflict_token);
  new_window = dc_ref(new trace_window_dc("Keyword Anomaly Trace", 
					  stack, sn, tn, fn));
  delete_tsd(stack);
  return new_window;
}

dc_ref anomaly_table_dc::derive_rule(unsigned ln) {
  LOGSECTION("anomaly_table_dc::derive_rule");
  int sn,tn,fn,rs;

  ln /= 2;
  xtx(key_mess,ln, &sn, &tn, &fn, &rs);
  find_anomaly(sn, tn, fn);
  return build_rule_derivation(sn, fn);
}

void anomaly_table_dc::getLine(unsigned ln) const {
  LOGSECTION("anomaly_table_dc::getLine");
  int sn, tn, fn, rs;
  //unsigned char *ks;
  int parity = ln % 2;

  ln /= 2;
  xtx(key_mess, ln, &sn, &tn, &fn, &rs);
  //ks = (unsigned char *) dict_str(key_dict,map_token_number[tn].key);
  //ks = (unsigned char *) Keyword(map_token_number[tn].key)->string.pointer();
  //ks = (unsigned char *) map_token_number[tn].key->string.pointer();
  //if (parity == 0) ssprintf("S%03d:  T%03d = \"%s\"",sn,tn,ks);
  //if (parity == 0) ssprintf("S%03d:\tT%03d\t=\t\"%s\"",sn,tn,ks);
  if (parity == 0) {
    ssprintf("S%03d:\tT%03d\t=\t", sn, tn);
    atkn(tn);
  }
  else {
    //sss("       ");
    sss("\t");
    append_item(fn, -1);
  }
}

//#ifndef OLDUI
int anomaly_table_dc::reduction_states_ok(unsigned ln) {
  LOGSECTION("anomaly_table_dc::reduction_states_ok");
  int sn, tn, fn, rs;

  ln /= 2;
  xtx(key_mess, ln, &sn, &tn, &fn, &rs);
  return reduction_states_window_ok(fn, Rule(fn)->length());
}
//#endif

dc_ref anomaly_table_dc::reduction_states(unsigned ln) {
  LOGSECTION("anomaly_table_dc::reduction_states");
  int sn, tn, fn, rs;

  ln /= 2;
  xtx(key_mess, ln, &sn, &tn, &fn, &rs);
  return reduction_states_window(sn,fn,Rule(fn)->length());
}

dc_ref anomaly_table_dc::reduction_trace(unsigned ln) {
  LOGSECTION("anomaly_table_dc::reduction_trace");
  int sn, tn, fn, rs;

  ln /= 2;
  xtx(key_mess, ln, &sn, &tn, &fn, &rs);
  find_anomaly(sn, tn, fn);
  return build_red_trace(sn, tn, fn);
}

dc_ref anomaly_table_dc::state_definition(unsigned ln) {
  LOGSECTION("anomaly_table_dc::state_definition");
  int sn, tn, fn, rs;

  ln /= 2;
  xtx(key_mess, ln, &sn, &tn, &fn, &rs);
  return conflict_state_window(sn);
}

void anomaly_table_dc::synchCursor(unsigned ln) const {
  LOGSECTION("anomaly_table_dc::synch_cursor");
  int sn, tn, fn, rs;
  xtx(key_mess, ln/2, &sn, &tn, &fn, &rs);
  if (fn) {
    set_rule_line(fn);
  }
}


/* End ANOM.C */