home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Professional
/
OS2PRO194.ISO
/
os2
/
prgramer
/
adaptor
/
src
/
buildtre.c
< prev
next >
Wrap
Text File
|
1994-01-02
|
8KB
|
390 lines
# include "BuildTre.h"
# include "yyBTree.w"
# include <stdio.h>
# if defined __STDC__ | defined __cplusplus
# include <stdlib.h>
# else
extern void exit ();
# endif
# include "Tree.h"
# ifndef NULL
# define NULL 0L
# endif
# ifndef false
# define false 0
# endif
# ifndef true
# define true 1
# endif
# ifdef yyInline
# define yyALLOC(tree, free, max, alloc, nodesize, make, ptr, kind) \
if ((ptr = (tree) free) >= (tree) max) ptr = alloc (); \
free += nodesize [kind]; \
ptr->yyHead.yyMark = 0; \
ptr->Kind = kind;
# else
# define yyALLOC(tree, free, max, alloc, nodesize, make, ptr, kind) ptr = make (kind);
# endif
# define yyWrite(s) (void) fputs (s, yyf)
# define yyWriteNl (void) fputc ('\n', yyf)
# line 26 "BuildTree.puma"
static FILE * yyf = stdout;
static void yyAbort
# ifdef __cplusplus
(char * yyFunction)
# else
(yyFunction) char * yyFunction;
# endif
{
(void) fprintf (stderr, "Error: module BuildTree, routine %s failed\n", yyFunction);
exit (1);
}
tTree ConcatDecls ARGS((tTree list1, tTree list2));
tTree CompleteDecls ARGS((tTree list));
void SetImplicitType ARGS((tTree declist, tTree type));
void SetIntent ARGS((tTree declist, int intent));
static void SetNewAttributes ARGS((tTree attlist, tTree entity, bool is_last));
void SetAttributes ARGS((tTree attlist, tTree entlist));
tTree IndependentForall ARGS((tTree loop));
tTree ConcatDecls
# if defined __STDC__ | defined __cplusplus
(register tTree list1, register tTree list2)
# else
(list1, list2)
register tTree list1;
register tTree list2;
# endif
{
# line 40 "BuildTree.puma"
{
# line 41 "BuildTree.puma"
if (! ((list1 == NoTree))) goto yyL1;
}
return list2;
yyL1:;
if (list1->Kind == kDECL_EMPTY) {
# line 45 "BuildTree.puma"
return list2;
}
if (list1->Kind == kDECL_LIST) {
# line 49 "BuildTree.puma"
{
# line 50 "BuildTree.puma"
list1->DECL_LIST.Next = ConcatDecls (list1->DECL_LIST.Next, list2);
}
return list1;
}
yyAbort ("ConcatDecls");
}
tTree CompleteDecls
# if defined __STDC__ | defined __cplusplus
(register tTree list)
# else
(list)
register tTree list;
# endif
{
# line 56 "BuildTree.puma"
{
# line 57 "BuildTree.puma"
if (! ((list == NoTree))) goto yyL1;
}
return mDECL_EMPTY ();
yyL1:;
if (list->Kind == kDECL_EMPTY) {
# line 61 "BuildTree.puma"
return list;
}
if (list->Kind == kDECL_LIST) {
# line 65 "BuildTree.puma"
{
# line 66 "BuildTree.puma"
list->DECL_LIST.Next = CompleteDecls (list->DECL_LIST.Next);
}
return list;
}
yyAbort ("CompleteDecls");
}
void SetImplicitType
# if defined __STDC__ | defined __cplusplus
(register tTree declist, register tTree type)
# else
(declist, type)
register tTree declist;
register tTree type;
# endif
{
if (declist == NoTree) return;
if (type == NoTree) return;
# line 78 "BuildTree.puma"
{
# line 79 "BuildTree.puma"
if (! ((declist == NoTree))) goto yyL1;
}
return;
yyL1:;
if (declist->Kind == kDECL_LIST) {
if (declist->DECL_LIST.Elem->Kind == kIMPLICIT_DECL) {
# line 82 "BuildTree.puma"
{
# line 83 "BuildTree.puma"
declist->DECL_LIST.Elem->IMPLICIT_DECL.VAL = type;
# line 84 "BuildTree.puma"
SetImplicitType (declist->DECL_LIST.Next, type);
}
return;
}
# line 87 "BuildTree.puma"
{
# line 88 "BuildTree.puma"
SetImplicitType (declist->DECL_LIST.Next, type);
}
return;
}
# line 91 "BuildTree.puma"
{
# line 92 "BuildTree.puma"
printf ("illegal call of SetImplicitType\n");
# line 93 "BuildTree.puma"
WriteTree (stdout, declist);
}
return;
;
}
void SetIntent
# if defined __STDC__ | defined __cplusplus
(register tTree declist, register int intent)
# else
(declist, intent)
register tTree declist;
register int intent;
# endif
{
if (declist == NoTree) return;
# line 104 "BuildTree.puma"
{
# line 105 "BuildTree.puma"
if (! ((declist == NoTree))) goto yyL1;
}
return;
yyL1:;
if (declist->Kind == kDECL_LIST) {
if (declist->DECL_LIST.Elem->Kind == kINTENT_DECL) {
# line 108 "BuildTree.puma"
{
# line 109 "BuildTree.puma"
declist->DECL_LIST.Elem->INTENT_DECL.intent = intent;
# line 110 "BuildTree.puma"
SetIntent (declist->DECL_LIST.Next, intent);
}
return;
}
}
# line 113 "BuildTree.puma"
{
# line 114 "BuildTree.puma"
printf ("illegal call of SetIntent\n");
# line 115 "BuildTree.puma"
WriteTree (stdout, declist);
}
return;
;
}
static void SetNewAttributes
# if defined __STDC__ | defined __cplusplus
(register tTree attlist, register tTree entity, register bool is_last)
# else
(attlist, entity, is_last)
register tTree attlist;
register tTree entity;
register bool is_last;
# endif
{
if (attlist == NoTree) return;
if (entity == NoTree) return;
# line 132 "BuildTree.puma"
{
# line 133 "BuildTree.puma"
if (! ((attlist == NoTree))) goto yyL1;
}
return;
yyL1:;
if (attlist->Kind == kDECL_LIST) {
if (entity->Kind == kENTITY_DECL) {
# line 136 "BuildTree.puma"
{
# line 137 "BuildTree.puma"
if (! ((is_last == true))) goto yyL2;
{
# line 138 "BuildTree.puma"
SetNewAttributes (attlist->DECL_LIST.Next, entity, is_last);
# line 139 "BuildTree.puma"
attlist->DECL_LIST.Next = entity->ENTITY_DECL.ATTRIBUTES;
entity->ENTITY_DECL.ATTRIBUTES = attlist;
}
}
return;
yyL2:;
# line 144 "BuildTree.puma"
{
# line 145 "BuildTree.puma"
if (! ((is_last != true))) goto yyL3;
{
# line 146 "BuildTree.puma"
SetNewAttributes (attlist->DECL_LIST.Next, entity, is_last);
# line 147 "BuildTree.puma"
entity->ENTITY_DECL.ATTRIBUTES = mDECL_LIST (CopyTree (attlist->DECL_LIST.Elem), entity->ENTITY_DECL.ATTRIBUTES);
}
}
return;
yyL3:;
}
}
# line 150 "BuildTree.puma"
{
# line 151 "BuildTree.puma"
printf ("illegal call of SetNewAttributes\n");
# line 152 "BuildTree.puma"
WriteTree (stdout, attlist);
}
return;
;
}
void SetAttributes
# if defined __STDC__ | defined __cplusplus
(register tTree attlist, register tTree entlist)
# else
(attlist, entlist)
register tTree attlist;
register tTree entlist;
# endif
{
if (attlist == NoTree) return;
if (entlist == NoTree) return;
# line 170 "BuildTree.puma"
{
# line 171 "BuildTree.puma"
if (! ((entlist == NoTree))) goto yyL1;
}
return;
yyL1:;
if (entlist->Kind == kDECL_LIST) {
if (entlist->DECL_LIST.Elem->Kind == kENTITY_DECL) {
# line 175 "BuildTree.puma"
{
bool is_last;
{
# line 177 "BuildTree.puma"
# line 179 "BuildTree.puma"
is_last = (entlist->DECL_LIST.Next == NoTree);
SetNewAttributes (attlist, entlist->DECL_LIST.Elem, is_last);
# line 182 "BuildTree.puma"
SetAttributes (attlist, entlist->DECL_LIST.Next);
}
return;
}
}
}
# line 185 "BuildTree.puma"
{
# line 186 "BuildTree.puma"
printf ("illegal call of SetAttributes\n");
# line 187 "BuildTree.puma"
WriteTree (stdout, entlist);
}
return;
;
}
tTree IndependentForall
# if defined __STDC__ | defined __cplusplus
(register tTree loop)
# else
(loop)
register tTree loop;
# endif
{
if (loop->Kind == kACF_FORALL) {
# line 201 "BuildTree.puma"
{
tTree newloop;
{
# line 202 "BuildTree.puma"
# line 203 "BuildTree.puma"
loop->ACF_FORALL.FORALL_BODY = IndependentForall (loop->ACF_FORALL.FORALL_BODY);
newloop = mACF_DOALL (mBTV_EMPTY (), loop->ACF_FORALL.FORALL_ID, loop->ACF_FORALL.FORALL_RANGE, loop->ACF_FORALL.FORALL_BODY);
newloop->ACF_DOALL.Label = loop->ACF_FORALL.Label;
newloop->ACF_DOALL.Line = loop->ACF_FORALL.Line;
}
{
return newloop;
}
}
}
if (loop->Kind == kACF_LIST) {
if (loop->ACF_LIST.Elem->Kind == kACF_FORALL) {
if (loop->ACF_LIST.Next->Kind == kACF_EMPTY) {
# line 211 "BuildTree.puma"
{
# line 212 "BuildTree.puma"
loop->ACF_LIST.Elem = IndependentForall (loop->ACF_LIST.Elem);
}
return loop;
}
}
}
# line 216 "BuildTree.puma"
return loop;
}
void BeginBuildTree ()
{
}
void CloseBuildTree ()
{
}