view anagram/guisupport/tokentabdc.cpp @ 20:bb115deb6fb2

Improve agfiles rule. (1) It didn't depend on $(AGCL) and it absolutely should have. (2) allow AGFORCE=1 to make it rebuild whether or not it looks out of date. (3) Document this.
author David A. Holland
date Mon, 13 Jun 2022 00:02:15 -0400
parents 13d2b8934445
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.
 *
 * tokentabdc.cpp
 */

#include "dc.h"
#include "items.h"
#include "q1glbl.h"
#include "rule.h"
#include "stacks.h"
#include "tokentabdc.h"
#include "ut.h"
#include "ws.h"


static int token_table_tabs[] = {6,9,13,21,0};

token_table_dc::token_table_dc(void)
  : dc("Token Table")
{
  tab_stops = token_table_tabs;
  columnHeadTitle = "Token\tFlags\tPrec\tType\tName";
  //des->c_size = cursor_bar_size;
  des->d_size.y = ntkns;
  //getWidth();
  //resize_window();
}

void token_table_dc::getLine(unsigned ln) const {
  token_number_map tm;
  const char *zl;
  char as;
  char *ts;
  char prbuf[20] = "   ";

  ln++;
  tm = map_token_number[ln];
  zl = tm.zero_length_flag ? "zl" : tm.non_terminal_flag ? "nt" : "  ";
  if (tm.precedence_level) {
    as = tm.left_associative ? 'l' : tm.right_associative ? 'r' : 'n';
    sprintf(prbuf, "%c%02d", as, tm.precedence_level);
  }
  else if (tm.sticky) {
    strcpy(prbuf, "s  ");
  }
  //ts = dict_str(cast_dict,tm.value_type);
  ts = Cast(tm.value_type)->pointer();
  ssprintf("T%03d\t%s\t%s\t(%s)\t", ln, zl, prbuf, ts);
  atkn(ln);
}

int token_table_dc::expansion_rules_ok(unsigned ln) {
  return build_item_list_ok(ln+1);
}

dc_ref token_table_dc::expansion_rules(unsigned ln) {
  return build_item_list(ln+1);
}

int token_table_dc::productions_ok(unsigned ln) {
  return productions_window_ok(ln+1);
}

dc_ref token_table_dc::productions(unsigned ln) {
  return productions_window(ln+1);
}

int token_table_dc::set_elements_ok(unsigned ln) {
  return token_set_window_ok(ln+1);
}

dc_ref token_table_dc::set_elements(unsigned ln) {
  return token_set_window(ln+1);
}

int token_table_dc::usage_ok(unsigned ln) {
  return token_usage_window_ok(ln+1);
}

dc_ref token_table_dc::usage(unsigned ln) {
  return token_usage_window(ln+1);
}