view anagram/guisupport/proctabdc.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.
 *
 * proctabdc.cpp
 */

//#include "brt.h"
#include "dc.h"
#include "proctabdc.h"
#include "rproc.h"
#include "rule.h"
#include "stacks.h"
#include "ut.h"
#include "wm1.h"

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


/*
void string_table_dc::init(void) {
  //LOGSECTION("string_table_dc::init");

  int width = 0;
  int nLines = text.size();

  for (int i = 0; i < nLines; i++) {
    width = max(width,text[i].size());
    //LOGV(text[i].pointer());
  }

  syntax_dependent = 0;
  //des->c_size = cursor_bar_size;
  des->d_size = cint(width, nLines);
}

void string_table_dc::reset(AgString name, AgArray<AgString> text_) {
  text = text_;
  head_title = name;
  init();
}

string_table_dc::string_table_dc(const AgString name, AgArray<AgString> text_)
  : dc(name)
  , text(text_)
{
  init();
  //sorted = 1;
  //resize_window();
}

void string_table_dc::getLine(unsigned ln) const {
  sss(text[ln].pointer());
}
*/
//extern int       rule_coverage;
//extern unsigned *rule_counts;

static int proc_table_tabs[] = {0,0};

proc_table_dc::proc_table_dc(void)
  : dc("Reduction Procedures")
{
  //des->c_size = cursor_bar_size;
  //des->d_size.y = n_auto_procs;
  des->d_size.y = Procedure::count() - 1;
  tab_stops = proc_table_tabs;
  //getWidth();
  //resize_window();
}

void proc_table_dc::getLine(unsigned ln) const {
  //proc_name_map pm;
  const char *cast, *cs;
  unsigned i;
  //char counts[20] = "";
  //int showCounts = rule_coverage && rule_counts != 0;

  ln++;
  //pm = map_proc_name[ln];
  Procedure proc(ln);
  Rule rule = proc->form_number;
  //tab_stops[0] = showCounts ? 7 : 0;
  tab_stops[0] = 0;
  //if (showCounts) sprintf(counts,"%5u\t", rule_counts[pm.form_number]);
  //cast = dict_str(cast_dict, pm.cast);
  //cast = dict_str(cast_dict, proc->cast);
  cast = Cast(proc->cast)->pointer();
  //assert(pm.cast == proc->cast);
  if (cast == NULL) {
    cast = "";
  }
  //ssprintf("%s%s %s(", counts, cast, proc_name_string(ln).pointer());
  ssprintf("%s %s(", cast, proc_name_string(ln).pointer());

  cs = "";
/*
  for (i = 0; i < pm.n_params; i++) {
    apprintf("%s%s",cs, dict_str(cast_dict,lstptr(pm,cast)[i]));
    cs = ", ";
  }
*/
  AgArray<RuleElement> elementList = rule->op_bias ? rule->hostElementList : rule->elementList;
  for (i = 0; i < elementList.size(); i++) {
    RuleElement &element = elementList[i];
    if (element.cVariable == 0) {
      continue;
    }
    //apprintf("%s%s", cs, dict_str(cast_dict,element.token->value_type));
    apprintf("%s%s", cs, Cast(element.token->value_type)->pointer());
    cs = ", ";
  }
  acs(')');
}

void proc_table_dc::synchCursor(unsigned ln) const {
  Procedure proc(ln+1);
  set_text_line(proc->line, proc->col, 0);
/*
  proc_name_map *mpn = &map_proc_name[ln+1];
  set_text_line(mpn->line, mpn->col,0);
*/
}