view anagram/guisupport/ws.h @ 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-2002 Parsifal Software. All Rights Reserved.
 * See the file COPYING for license and usage terms.
 *
 * ws.h
 */

#ifndef WS_H
#define WS_H

#include "agarray.h"
#include "dc.h"
#include "tsd.h"

int      productions_window_ok(int);
dc_ref   productions_window(int);
int      token_usage_window_ok(unsigned);
dc_ref   token_usage_window(unsigned);
dc_ref   rule_context_window(int);
tsd     *build_states_table(unsigned *, int);
dc_ref   previous_states_window(int);
int      previous_states_window_ok(int);
dc_ref   conflict_state_window(unsigned);
int      keywords_window_ok(int);
dc_ref   keywords_window(int);
int      reduction_states_window_ok(int, int);
dc_ref   reduction_states_window(int, int, int);
// this appears to be spurious
//int      reduction_states_window_ok(int, int, int);
tsd *make_stored_trace(int *trace, int depth, int tn);
dc_ref   aux_trace_window(unsigned);
int      token_set_window_ok(int);
dc_ref   token_set_window(int);
int      char_set_window_ok(int cs);
dc_ref   char_set_window(int cs);

class productions_window_dc : public dc {
public:
  unsigned token_number;

  productions_window_dc(unsigned, const AgString);
  productions_window_dc(productions_window_dc &x)
  : dc(x), token_number(x.token_number) {}

  virtual void getLine(unsigned) const;
  virtual void synchCursor(unsigned) const;
};

class rule_list_dc : public dc {
public:
  const AgArray<int> rule_list;

  static MenuOption *auxTable[];
  virtual MenuOption **getAuxWinMenu(void) {return auxTable;}

  rule_list_dc(const AgArray<int>, const AgString, const AgString);
  rule_list_dc(rule_list_dc &x)
  : dc(x), rule_list(x.rule_list) {}

  virtual unsigned token(unsigned);

  virtual void getLine(unsigned) const;
  virtual void synchCursor(unsigned) const;

  virtual dc_ref expansion_rules(unsigned ln);
  virtual dc_ref productions(unsigned ln);
  virtual dc_ref rule_context(unsigned ln);
  virtual dc_ref set_elements(unsigned ln);
  virtual dc_ref usage(unsigned ln);

  virtual int expansion_rules_ok(unsigned ln);
  virtual int productions_ok(unsigned ln);
  virtual int rule_context_ok(unsigned ln) {return ln != 0;}
  virtual int set_elements_ok(unsigned ln);
  virtual int usage_ok(unsigned ln);
};

class rule_context_dc : public rule_list_dc {
public:
  rule_context_dc(const AgArray<int> list, const AgString foot)
  : rule_list_dc(list, AgString("Rule Context"), foot)
  {
  }
};

class usage_dc : public rule_list_dc {
public:
  usage_dc(const AgArray<int> list, const AgString foot)
  : rule_list_dc(list, "Token Usage", foot)
  {
  }
};

class state_list_dc : public dc {
public:
  tsd *state_list;
  static MenuOption *auxTable[];
  virtual MenuOption **getAuxWinMenu(void) {return auxTable;}

  state_list_dc(const AgString, tsd*, const AgString);
  state_list_dc(state_list_dc &x) : dc(x), state_list(x.state_list) {}
  ~state_list_dc(void) {delete_tsd(state_list);}

  virtual unsigned token(unsigned) const;
  virtual unsigned rule(unsigned) const;
  virtual unsigned state(unsigned) const;

  virtual void getLine(unsigned) const;
  virtual void synchCursor(unsigned) const;
  virtual dc_ref aux_trace(unsigned ln) {
    return aux_trace_window(state(ln));
  }
  virtual int expansion_rules_ok(unsigned);
  virtual dc_ref expansion_rules(unsigned);
  virtual int keywords_ok(unsigned ln) {
    return keywords_window_ok(state(ln));
  }
  virtual dc_ref keywords(unsigned ln) {
    return keywords_window(state(ln));
  }
  virtual int previous_states_ok(unsigned ln) {
    return previous_states_window_ok(state(ln));
  }
  virtual dc_ref previous_states(unsigned ln) {
    return previous_states_window(state(ln));
  }
  virtual int productions_ok(unsigned ln) {
    return productions_window_ok(token(ln));
  }
  virtual dc_ref productions(unsigned ln) {
    return productions_window(token(ln));
  }
  virtual int reduction_states_ok(unsigned);
  virtual dc_ref reduction_states(unsigned);
  virtual int rule_context_ok(unsigned ln) { return ln != 0; }
  virtual dc_ref rule_context(unsigned);
  virtual int set_elements_ok(unsigned);
  virtual dc_ref set_elements(unsigned);
  virtual dc_ref state_expansion(unsigned);
  virtual int usage_ok(unsigned);
  virtual dc_ref usage(unsigned);
};

class keywords_dc : public dc {
public:
  static MenuOption *auxTable[];
  virtual MenuOption **getAuxWinMenu(void) { return auxTable; }
  unsigned *keyword_list;

  keywords_dc(unsigned *, unsigned, const AgString);
  keywords_dc(keywords_dc &x)
  : dc(x), keyword_list(x.keyword_list) {}

  virtual void getLine(unsigned) const;
  //virtual dc_ref onCloneKey(void) { return new keywords_dc(*this); }

  virtual dc_ref usage(unsigned);
  virtual int usage_ok(unsigned);
};

#endif /* WS_H */