EDK2 doxygen online documents - Firmware Encoding Index 1
EDK2 doxygen online documents - Firmware Encoding Index

BaseTools/Source/C/VfrCompile/Pccts/dlg/dlg.h

Go to the documentation of this file.
00001 /* dlg header file
00002  *
00003  * SOFTWARE RIGHTS
00004  *
00005  * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
00006  * Set (PCCTS) -- PCCTS is in the public domain.  An individual or
00007  * company may do whatever they wish with source code distributed with
00008  * PCCTS or the code generated by PCCTS, including the incorporation of
00009  * PCCTS, or its output, into commerical software.
00010  *
00011  * We encourage users to develop software with PCCTS.  However, we do ask
00012  * that credit is given to us for developing PCCTS.  By "credit",
00013  * we mean that if you incorporate our source code into one of your
00014  * programs (commercial product, research project, or otherwise) that you
00015  * acknowledge this fact somewhere in the documentation, research report,
00016  * etc...  If you like PCCTS and have developed a nice tool with the
00017  * output, please mention that you developed it using PCCTS.  In
00018  * addition, we ask that this header remain intact in our source code.
00019  * As long as these guidelines are kept, we expect to continue enhancing
00020  * this system and expect to make other tools available as they are
00021  * completed.
00022  *
00023  * DLG 1.33
00024  * Will Cohen
00025  * With mods by Terence Parr; AHPCRC, University of Minnesota
00026  * 1989-2001
00027  */
00028 
00029 /* MR1 Move pcctscfg.h to top of file                                   */
00030 
00031 #include "pcctscfg.h"                                           
00032 
00033 /* turn off warnings for unreferenced labels */
00034 
00035 #ifdef _MSC_VER
00036 #pragma warning(disable:4102)
00037 #endif
00038 
00039 #include "set.h"
00040 
00041 #define TRUE    1
00042 #define FALSE   0
00043 
00044 /***** output related stuff *******************/
00045 #define IN      input_stream
00046 #define OUT     output_stream
00047 
00048 #define MAX_MODES       50      /* number of %%names allowed */
00049 #define MAX_ON_LINE     10
00050 
00051 #define NFA_MIN         64      /* minimum nfa_array size */
00052 #define DFA_MIN         64      /* minimum dfa_array size */
00053 
00054 #define DEFAULT_CLASSNAME "DLGLexer"
00055 
00056 /* these macros allow the size of the character set to be easily changed */
00057 /* NOTE: do NOT change MIN_CHAR since EOF is the lowest char, -1 */
00058 #define MIN_CHAR (-1)   /* lowest possible character possible on input */
00059 #define MAX_CHAR 255    /* highest possible character possible on input */
00060 #define CHAR_RANGE (1+(MAX_CHAR) - (MIN_CHAR))
00061 
00062 /* indicates that the not an "array" reference */
00063 #define NIL_INDEX 0
00064 
00065 /* size of hash table used to find dfa_states quickly */
00066 #define HASH_SIZE 211
00067 
00068 #define nfa_node struct _nfa_node
00069 nfa_node {
00070         int             node_no;
00071         int             nfa_set;
00072         int             accept; /* what case to use */
00073         nfa_node        *trans[2];
00074         set             label;  /* one arc always labelled with epsilon */
00075 };
00076 
00077 #define dfa_node struct _dfa_node
00078 dfa_node {
00079         int             node_no;
00080         int             dfa_set;
00081         int             alternatives;   /* used for interactive mode */
00082                                         /* are more characters needed */
00083         int             done;
00084         set             nfa_states;
00085         int             trans[1];/* size of transition table depends on
00086                                   * number of classes required for automata.
00087                                   */
00088 
00089 
00090 };
00091 
00092 /******** macros for accessing the NFA and DFA nodes ****/
00093 #define NFA(x)  (nfa_array[x])
00094 #define DFA(x)  (dfa_array[x])
00095 #define DFA_NO(x) ( (x) ? (x)->node_no : NIL_INDEX)
00096 #define NFA_NO(x) ( (x) ? (x)->node_no : NIL_INDEX)
00097 
00098 /******** wrapper for memory checking ***/
00099 /*#define malloc(x)     dlg_malloc((x),__FILE__,__LINE__)*/
00100 
00101 /*#define calloc(x,y)   dlg_calloc((x),(y),__FILE__,__LINE__)*/
00102 
00103 /******** antlr attributes *************/
00104 typedef struct {
00105         unsigned char letter;
00106         nfa_node *l,*r;
00107         set label;
00108         } Attrib;
00109 
00110 #define zzcr_attr(attr, token, text) {                                  \
00111         (attr)->letter = text[0]; (attr)->l = NULL;                     \
00112         (attr)->r = NULL; (attr)->label = empty;                        \
00113 }
00114 #define zzd_attr(a)     set_free((a)->label);
00115 
00116 /******************** Variable ******************************/
00117 extern char     program[];      /* tells what program this is */
00118 extern char     version[];      /* tells what version this is */
00119 extern char     *file_str[];    /* file names being used */
00120 extern int      err_found;      /* flag to indicate error occured */
00121 extern int      action_no;      /* last action function printed */
00122 extern int      func_action;    /* should actions be turned into functions?*/
00123 extern set      used_chars;     /* used to label trans. arcs */
00124 extern set      used_classes;   /* classes or chars used to label trans. arcs */
00125 extern int      class_no;       /* number of classes used */
00126 extern set      class_sets[];   /* shows char. in each class */
00127 extern set      normal_chars;   /* mask off unused portion of set */
00128 extern int      comp_level;     /* what compression level to use */
00129 extern int      interactive;    /* interactive scanner (avoid lookahead)*/
00130 extern int      mode_counter;   /* keeps track of the number of %%name */
00131 extern int      dfa_basep[];    /* start of each group of dfa */
00132 extern int      dfa_class_nop[];/* number of transistion arcs in */
00133                                 /* each dfa in each mode */
00134 extern int      nfa_allocated;
00135 extern int      dfa_allocated;
00136 extern nfa_node **nfa_array;    /* start of nfa "array" */
00137 extern dfa_node **dfa_array;    /* start of dfa "array" */
00138 extern int      operation_no;   /* unique number for each operation */
00139 extern FILE     *input_stream;  /* where description read from */
00140 extern FILE     *output_stream; /* where to put the output */
00141 extern FILE     *mode_stream;   /* where to put the mode output */
00142 extern FILE     *class_stream;
00143 extern char     *mode_file;     /* name of file for mode output */
00144 extern int      gen_ansi;       /* produce ansi compatible code */
00145 extern int      case_insensitive;/* ignore case of input spec. */
00146 extern int      warn_ambig;     /* show if regular expressions ambiguous */
00147 extern int      gen_cpp;
00148 extern char *cl_file_str;
00149 extern int      firstLexMember; /* MR1 */
00150 extern char *OutputDirectory;
00151 extern char     *class_name;
00152 
00153 /******************** Functions ******************************/
00154 #ifdef __USE_PROTOS
00155 extern char     *dlg_malloc(int, char *, int); /* wrapper malloc */
00156 extern char     *dlg_calloc(int, int, char *, int); /* wrapper calloc */
00157 extern int      reach(unsigned *, register int, unsigned *);
00158 extern set      closure(set *, unsigned *);
00159 extern dfa_node *new_dfa_node(set);
00160 extern nfa_node *new_nfa_node(void);
00161 extern dfa_node *dfastate(set);
00162 extern dfa_node **nfa_to_dfa(nfa_node *);
00163 extern void     internal_error(char *, char *, int);    /* MR9 23-Sep-97 */
00164 extern FILE     *read_stream(char *);   /* opens file for reading */
00165 extern FILE     *write_stream(char *);  /* opens file for writing */
00166 extern void     make_nfa_model_node(void);
00167 extern void     make_dfa_model_node(int);
00168 extern char *ClassName(char *);
00169 extern char *OutMetaName(char *);
00170 extern void error(char*, int);
00171 extern void warning(char*, int);
00172 extern void p_head(void);
00173 extern void p_class_hdr(void);
00174 extern void p_includes(void);
00175 extern void p_tables(void);
00176 extern void p_tail(void);                                       /* MR1 */
00177 extern void p_class_def1(void);                         /* MR1 */
00178 extern void new_automaton_mode(void);                   /* MR1 */
00179 extern int  relabel(nfa_node *,int);                    /* MR1 */
00180 extern void p_shift_table(int);                         /* MR1 */
00181 extern void p_bshift_table(void);                               /* MR1 */
00182 extern void p_class_table(void);                                /* MR1 */
00183 extern void p_mode_def(char *,int);                     /* MR1 */
00184 extern void init(void);                                 /* MR1 */
00185 extern void p_class_def2(void);                         /* MR1 */
00186 extern void clear_hash(void);                           /* MR1 */
00187 extern void p_alternative_table(void);                  /* MR1 */
00188 extern void p_node_table(void);                         /* MR1 */
00189 extern void p_dfa_table(void);                          /* MR1 */
00190 extern void p_accept_table(void);                               /* MR1 */
00191 extern void p_action_table(void);                               /* MR1 */
00192 extern void p_base_table(void);                         /* MR1 */
00193 extern void p_single_node(int,int);                     /* MR1 */
00194 extern char * minsize(int);                             /* MR1 */
00195 extern void close1(nfa_node *,int,set *);               /* MR1 */
00196 extern void partition(nfa_node *,int);                  /* MR1 */
00197 extern void intersect_nfa_labels(nfa_node *,set *);     /* MR1 */
00198 extern void r_intersect(nfa_node *,set *);              /* MR1 */
00199 extern void label_node(nfa_node *);                     /* MR1 */
00200 extern void label_with_classes(nfa_node *);             /* MR1 */
00201 
00202 #else
00203 extern char *dlg_malloc();      /* wrapper malloc */
00204 extern char *dlg_calloc();      /* wrapper calloc */
00205 extern int      reach();
00206 extern set      closure();
00207 extern dfa_node *new_dfa_node();
00208 extern nfa_node *new_nfa_node();
00209 extern dfa_node *dfastate();
00210 extern dfa_node **nfa_to_dfa();
00211 extern void     internal_error();   /* MR9 23-Sep-97 */
00212 extern FILE     *read_stream();         /* opens file for reading */
00213 extern FILE     *write_stream();        /* opens file for writing */
00214 extern void     make_nfa_model_node();
00215 extern void     make_dfa_model_node();
00216 extern char *ClassName();
00217 extern char *OutMetaName();
00218 extern void error();
00219 extern void warning();
00220 extern void p_head();                   /* MR9 */
00221 extern void p_class_hdr();              /* MR9 */
00222 extern void p_includes();               /* MR9 */
00223 extern void p_tables();                 /* MR9 */
00224 extern void p_tail();                                   /* MR1 */
00225 extern void p_class_def1();                             /* MR1 */
00226 extern void new_automaton_mode();                       /* MR1 */
00227 extern int  relabel();                                  /* MR1 */
00228 extern void p_shift_table();                            /* MR1 */
00229 extern void p_bshift_table();                           /* MR1 */
00230 extern void p_class_table();                            /* MR1 */
00231 extern void p_mode_def();                               /* MR1 */
00232 extern void init();                                     /* MR1 */
00233 extern void p_class_def2();                             /* MR1 */
00234 extern void clear_hash();                               /* MR1 */
00235 extern void p_alternative_table();                      /* MR1 */
00236 extern void p_node_table();                             /* MR1 */
00237 extern void p_dfa_table();                              /* MR1 */
00238 extern void p_accept_table();                           /* MR1 */
00239 extern void p_action_table();                           /* MR1 */
00240 extern void p_base_table();                             /* MR1 */
00241 extern void p_single_node();                            /* MR1 */
00242 extern char * minsize();                                /* MR1 */
00243 extern void close1();                                   /* MR1 */
00244 extern void partition();                                /* MR1 */
00245 extern void intersect_nfa_labels();                     /* MR1 */
00246 extern void r_intersect();                              /* MR1 */
00247 extern void label_node();                               /* MR1 */
00248 extern void label_with_classes();                       /* MR1 */
00249 
00250 #endif
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Defines