1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
/*
* cccc_ast.h
* definition of the abstract syntax tree interface for the cccc project
*/
#ifndef __CCCC_AST_H
#define __CCCC_AST_H
#include <string>
using std::string;
#include "cccc.h"
#include "ASTBase.h"
#include "ATokPtr.h"
#include "cccc_tok.h"
#include "AParser.h"
#include "cccc_utl.h"
class AST : public ASTBase {
friend ostream& operator << (ostream&, AST&);
public:
ANTLRToken token;
// elements to control output
int bPrintNode, bCanonicalElement;
// canonical name of the element
string canonical_name(); /* function to recursively generate the name */
static char *szCurrentRuleName;
char *szRuleName;
// first and last token
ANTLRToken *first_token();
ANTLRToken *last_token();
// start and end line of the source code covered by the AST
int nStartLine();
int nEndLine();
char *filename, *classname, *membername;
AST();
AST(ANTLRTokenPtr t);
AST(AST& ast);
virtual ~AST();
virtual AST& operator =(AST&);
void free_subtrees();
void preorder(ostream &os=cerr);
void preorder_action();
void preorder_before_action();
void preorder_after_action();
#if 0
/* supress the normal error reporting */
void syn(_ANTLRTokenPtr t,
ANTLRChar* c,
SetWordType* swt,
ANTLRTokenType att,
int i
) {}
#endif
};
ostream& operator << (ostream&, AST&);
#endif
|