view anagram/agcore/data.h @ 14:a02e9434072e

Fix friend declaration for gcc10. XXX: did not check it against the IBM compiler, might end up needing XXX: to be conditional.
author David A. Holland
date Tue, 31 May 2022 00:59:42 -0400
parents 13d2b8934445
children
line wrap: on
line source

/*
 * AnaGram, A System for Syntax Directed Programming
 * Copyright 1993 Parsifal Software. All Rights Reserved.
 * See the file COPYING for license and usage terms.
 *
 * data.h
 */

#ifndef DATA_H
#define DATA_H

#include <stdio.h>
#include "port.h"

struct list_dict; // from dict.h
struct tuple_dict; // from dict.h
struct tsd; // from tsd.h
#include "agstack.h"


enum syntax_states {
  syntax_reset,
  syntax_loaded,
  syntax_error,
  syntax_parsed,
  syntax_analyzed,
  engine_built
};

struct conflict_type {
  tsd *ct;
  int *pv;
  int ns;
};

class Problem {
public:
  char *msg;
  Problem(char *m) : msg(m) {}
  Problem(const Problem &problem) : msg(problem.msg) {}
};


template <class T>
struct Triple {
  T x, y, z;
public:
  Triple() : x(0), y(0), z(0) {}
  Triple(const T x_, const T y_, const T z_) : x(x_), y(y_), z(z_) {}
  Triple<T> &values(T &rx, T &ry, T&rz) { rx=x, ry=y, rz=z; return *this; }
  int operator < (const Triple<T> &t) const;
};

template <class T>
int Triple<T>::operator < (const Triple<T> &t) const {
  if (x < t.x) return 1;
  if (t.x < x) return 0;
  if (y < t.y) return 1;
  if (t.y < y) return 0;
  return z < t.z;
}


template <class T>
struct OrderedPair {
  T x, y;
public:
  OrderedPair() : x(0), y(0) {}
  OrderedPair(const T x_, const T y_) : x(x_), y(y_) {}
  OrderedPair<T> &values(T &rx, T &ry) { rx=x, ry=y; return *this; }
  int operator < (const OrderedPair<T> &t) const;
};

template <class T>
int OrderedPair<T>::operator < (const OrderedPair<T> &t) const {
  if (x < t.x) return 1;
  if (t.x < x) return 0;
  return y < t.y;
}

////////////////////////////////////////////////////////////

extern tuple_dict *frss_dict;

extern tsd *unres_con;
extern tsd *res_con;
extern int precedence_level;
extern int enum_base;

extern tsd *prr;
extern tsd *key_mess;
extern tsd *rename_macro_list;

extern int void_token_type;
extern int int_token_type;
extern int long_token_type;
extern unsigned nprods;

extern syntax_states syntax_state;

extern const char *syntaxStateString[];

struct char_set_map {
  unsigned part_index;
  int nparts;
  int parse_tree;
};

extern char_set_map *map_char_set;
extern unsigned *part_list;
extern unsigned *chars_list;

extern list_dict *char_set_dict;
extern list_dict *key_list_dict;
extern list_dict *part_dict;
extern list_dict *prod_dict;
extern list_dict *vp_prod_dict;

struct vp_prod_number_map {
  int token_number;
};

extern vp_prod_number_map *map_vp_prod_number;

extern unsigned *previous_states_list;
extern unsigned *completed_forms_list;
extern unsigned *gotos_list;
extern unsigned *reductions_list;
extern unsigned *a_actions_list;
extern unsigned *t_actions_list;
extern unsigned *p_actions_list;
extern unsigned *completions_list;
extern unsigned *chain_completions_list;
extern unsigned *chain_gotos_list;
extern unsigned *reduction_states_list;
extern unsigned nstates;

struct part_number_map {
  unsigned chars_index;
  int size;
  unsigned token_number;
};

extern part_number_map *map_part_number;

struct char_number_map {
  unsigned token_number;
  unsigned part_number;
  unsigned token_name;
};

extern char_number_map *map_char_number;
extern int max_char_number;
extern int min_char_number;
extern unsigned n_chars;

/* flags */

extern FILE *h_file;
extern FILE *pe_file;

extern char        *key_ends;
extern tsd         *key_table;
extern unsigned     n_key_ends;
extern int          max_key_length;

extern int character_seen;

extern AgStack<int> distinguishSets;

void init_data(void);
void reset_summary_data(void);
void reset_result_data(void);


#endif /* DATA_H */