1987-04-29 10:22:07 +00:00
|
|
|
/*
|
|
|
|
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
|
|
|
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
|
|
|
*
|
|
|
|
* Author: Ceriel J.H. Jacobs
|
|
|
|
*/
|
2019-05-10 17:09:03 +00:00
|
|
|
#ifndef NODE_H_
|
|
|
|
#define NODE_H_
|
|
|
|
|
|
|
|
#include "em_arith.h"
|
|
|
|
#include "em_label.h"
|
1987-04-29 10:22:07 +00:00
|
|
|
|
1986-04-06 17:42:56 +00:00
|
|
|
/* N O D E O F A N A B S T R A C T P A R S E T R E E */
|
|
|
|
|
2019-05-10 17:09:03 +00:00
|
|
|
|
1987-04-29 10:22:07 +00:00
|
|
|
|
1986-04-06 17:42:56 +00:00
|
|
|
struct node {
|
1988-03-22 17:54:01 +00:00
|
|
|
char nd_class; /* kind of node */
|
1986-06-10 13:18:52 +00:00
|
|
|
#define Value 0 /* constant */
|
|
|
|
#define Arrsel 1 /* array selection */
|
1986-04-06 17:42:56 +00:00
|
|
|
#define Oper 2 /* binary operator */
|
|
|
|
#define Uoper 3 /* unary operator */
|
1986-06-10 13:18:52 +00:00
|
|
|
#define Arrow 4 /* ^ construction */
|
|
|
|
#define Call 5 /* cast or procedure - or function call */
|
|
|
|
#define Name 6 /* an identifier */
|
|
|
|
#define Set 7 /* a set constant */
|
|
|
|
#define Xset 8 /* a set */
|
|
|
|
#define Def 9 /* an identified name */
|
|
|
|
#define Stat 10 /* a statement */
|
1991-03-12 16:52:00 +00:00
|
|
|
#define Select 11 /* a '.' selection */
|
|
|
|
#define Link 12
|
1986-06-17 12:04:05 +00:00
|
|
|
/* do NOT change the order or the numbers!!! */
|
1988-03-22 17:54:01 +00:00
|
|
|
char nd_flags; /* options */
|
|
|
|
#define ROPTION 1
|
|
|
|
#define AOPTION 2
|
1986-04-06 17:42:56 +00:00
|
|
|
struct type *nd_type; /* type of this node */
|
1986-04-09 18:14:49 +00:00
|
|
|
struct token nd_token;
|
|
|
|
#define nd_set nd_token.tk_data.tk_set
|
|
|
|
#define nd_def nd_token.tk_data.tk_def
|
1991-03-12 16:52:00 +00:00
|
|
|
#define nd_LEFT nd_token.tk_data.tk_left
|
|
|
|
#define nd_RIGHT nd_token.tk_data.tk_right
|
|
|
|
#define nd_NEXT nd_token.tk_data.tk_next
|
1986-04-06 17:42:56 +00:00
|
|
|
#define nd_symb nd_token.tk_symb
|
|
|
|
#define nd_lineno nd_token.tk_lineno
|
|
|
|
#define nd_IDF nd_token.TOK_IDF
|
1991-03-06 10:52:34 +00:00
|
|
|
#define nd_SSTR nd_token.TOK_SSTR
|
1986-04-06 17:42:56 +00:00
|
|
|
#define nd_STR nd_token.TOK_STR
|
|
|
|
#define nd_SLE nd_token.TOK_SLE
|
|
|
|
#define nd_INT nd_token.TOK_INT
|
1989-12-19 09:40:25 +00:00
|
|
|
#define nd_REAL nd_token.TOK_REAL
|
1991-03-06 10:52:34 +00:00
|
|
|
#define nd_RSTR nd_token.TOK_RSTR
|
1989-12-19 09:40:25 +00:00
|
|
|
#define nd_RVAL nd_token.TOK_RVAL
|
1986-04-06 17:42:56 +00:00
|
|
|
};
|
|
|
|
|
2022-07-16 17:34:25 +00:00
|
|
|
#define new_node() ((struct node*) calloc(1, sizeof(struct node)))
|
|
|
|
#define free_node(p) free(p)
|
1986-04-06 17:42:56 +00:00
|
|
|
|
2019-05-10 17:09:03 +00:00
|
|
|
extern struct node *dot2node(), *dot2leaf(), *getnode();
|
1986-04-06 17:42:56 +00:00
|
|
|
|
2019-05-10 17:09:03 +00:00
|
|
|
#define NULLNODE ((struct node *) 0)
|
1986-04-25 10:14:08 +00:00
|
|
|
|
1986-06-20 14:36:49 +00:00
|
|
|
#define HASSELECTORS 002
|
|
|
|
#define VARIABLE 004
|
|
|
|
#define VALUE 010
|
1986-05-30 18:48:00 +00:00
|
|
|
|
1987-08-11 10:50:30 +00:00
|
|
|
#define IsCast(lnd) ((lnd)->nd_class == Def && is_type((lnd)->nd_def))
|
1989-03-03 16:13:45 +00:00
|
|
|
#define IsProc(lnd) ((lnd)->nd_type->tp_fund == T_PROCEDURE)
|
2019-03-01 17:39:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2019-05-10 17:09:03 +00:00
|
|
|
struct node *getnode(int class);
|
|
|
|
struct node *dot2node(int class, struct node *left, struct node *right);
|
|
|
|
struct node *dot2leaf(int class);
|
|
|
|
void FreeNode(register struct node *nd);
|
|
|
|
int NodeCrash(register struct node* expp, label exit_label, int end_reached);
|
|
|
|
int PNodeCrash(struct node **expp, int flags);
|
2019-03-01 17:39:25 +00:00
|
|
|
|
2022-07-16 17:34:25 +00:00
|
|
|
#endif /* NODE_H_ */
|