]>
git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/C/VfrCompile/Pccts/h/PCCTSAST.h
1 /* Abstract syntax tree
5 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
6 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
7 * company may do whatever they wish with source code distributed with
8 * PCCTS or the code generated by PCCTS, including the incorporation of
9 * PCCTS, or its output, into commerical software.
11 * We encourage users to develop software with PCCTS. However, we do ask
12 * that credit is given to us for developing PCCTS. By "credit",
13 * we mean that if you incorporate our source code into one of your
14 * programs (commercial product, research project, or otherwise) that you
15 * acknowledge this fact somewhere in the documentation, research report,
16 * etc... If you like PCCTS and have developed a nice tool with the
17 * output, please mention that you developed it using PCCTS. In
18 * addition, we ask that this header remain intact in our source code.
19 * As long as these guidelines are kept, we expect to continue enhancing
20 * this system and expect to make other tools available as they are
25 * Parr Research Corporation
26 * with Purdue University and AHPCRC, University of Minnesota
35 #include "pccts_stdio.h"
36 #include "pccts_stdlib.h"
42 #define StringScanMaxText 50
43 #define MaxTreeStackDepth 400
46 // 7-Apr-97 133MR1 signed int not accepted by AT&T cfront
48 typedef struct stringlexer
{
52 char text
[StringScanMaxText
];
55 /* Define the structures needed for ast_scan() */
56 typedef struct stringparser
{
62 typedef struct _scanast
{
63 struct _scanast
*_right
, *_down
;
66 int type() { return _token
; }
67 struct _scanast
*right() { return _right
; }
68 struct _scanast
*down() { return _down
; }
71 #define VALID_SCAN_TOKEN(t) (t>=__LPAREN && t<=__PERIOD)
73 class DllExportPCCTS PCCTS_AST
{
75 static const char *scan_token_tbl
[]; /* MR20 const */
87 const char *scan_token_str(int t
); /* MR20 const */
88 void stringlexer_init(StringLexer
*scanner
, char *input
);
89 void stringparser_init(StringParser
*, StringLexer
*);
90 ScanAST
*stringparser_parse_scanast(char *templ
, int *n
);
91 ScanAST
*stringparser_parse_tree(StringParser
*parser
);
92 ScanAST
*stringparser_parse_element(StringParser
*parser
);
93 void stringscan_advance(StringLexer
*scanner
);
94 int stringscan_gettok(StringLexer
*scanner
);
95 void _push(PCCTS_AST
**st
, int *sp
, PCCTS_AST
*e
);
96 PCCTS_AST
*_pop(PCCTS_AST
**st
, int *sp
);
97 int match_partial(PCCTS_AST
*t
, PCCTS_AST
*u
);
98 int scanmatch(ScanAST
*t
, PCCTS_AST
**labels
[], int *n
);
99 void scanast_free(ScanAST
*t
);
100 ScanAST
*new_scanast(int tok
);
101 void stringparser_match(StringParser
*parser
, int type
);
102 virtual PCCTS_AST
*deepCopyBushy();
106 virtual ~PCCTS_AST() {;}
108 /* This group must be defined for SORCERER to work correctly */
109 virtual PCCTS_AST
*right() = 0;
110 virtual PCCTS_AST
*down() = 0;
111 virtual void setRight(PCCTS_AST
*t
) = 0;
112 virtual void setDown(PCCTS_AST
*t
) = 0;
113 // we define these so ANTLR doesn't have to
114 virtual int type() { return 0; }
115 virtual void setType(int /*t MR23 */) {;}
116 virtual PCCTS_AST
*shallowCopy() {panic("no shallowCopy() defined"); return NULL
;}
118 /* These are not needed by ANTLR, but are support functions */
119 virtual PCCTS_AST
*deepCopy(); // used by SORCERER in transform mode
120 virtual void addChild(PCCTS_AST
*t
);
121 virtual void lisp_action(FILE * /*f MR23 */) {;}
122 virtual void lisp(FILE *f
);
123 static PCCTS_AST
*make(PCCTS_AST
*rt
, ...);
124 virtual PCCTS_AST
*ast_find_all(PCCTS_AST
*u
, PCCTS_AST
**cursor
);
125 virtual int match(PCCTS_AST
*u
);
126 virtual void insert_after(PCCTS_AST
*b
);
127 virtual void append(PCCTS_AST
*b
);
128 virtual PCCTS_AST
*tail();
129 virtual PCCTS_AST
*bottom();
130 static PCCTS_AST
*cut_between(PCCTS_AST
*a
, PCCTS_AST
*b
);
131 // virtual SList *to_slist();
132 virtual void tfree();
133 int ast_scan(char *templ
, ...);
134 virtual int nsiblings();
135 virtual PCCTS_AST
*sibling_index(int i
);
137 void require(int e
,const char *err
){ if ( !e
) panic(err
); } /* MR20 const */
138 virtual void panic(const char *err
) // MR20 const
139 { /* MR23 */ printMessage(stderr
, "PCCTS_AST: %s\n", err
); exit(PCCTS_EXIT_FAILURE
); }
140 virtual int printMessage(FILE* pFile
, const char* pFormat
, ...); // MR23
143 #endif /* PCCTSAST_H */