3 extern int generatePVM;
4 extern int generateXDR;
7 #define YYSTYPE union parseStack
11 extern int emitHeader;
12 extern int generateTHREAD;
13 extern char *serverTypeName;
14 extern void *yyerror(char*);
15 extern List <typeDefn *> types;
16 extern typeDefn *foundType;
17 extern interfaceSpec *currentInterface;
20 %token tIDENT tCOMMA tARRAY tSTAR tNAME tBASE tINT tUPCALL tASYNC
21 %token tLPAREN tRPAREN tSEMI tLBLOCK tRBLOCK tCMEMBER tSMEMBER
22 %token tTYPEDEF tSTRUCT tVERSION tVIRTUAL
25 completeDefinition: parsableUnitList ;
28 | parsableUnit { extern int parsing; parsing = 0; }parsableUnitList;
30 parsableUnit: interfaceSpec
33 interfacePreamble: interfaceName tLBLOCK interfaceBase interfaceVersion {
36 is = new interfaceSpec($1.cp, $4.i, $3.i);
37 currentInterface = $$.spec = is;
40 interfaceSpec: interfacePreamble definitionList tRBLOCK tSEMI {
44 interfaceName: tIDENT { $$.cp = $1.cp; };
46 interfaceBase: tBASE tINT tSEMI { $$.i = $2.i; };
48 interfaceVersion: tVERSION tINT tSEMI { $$.i = $2.i; };
51 | definitionList definition
54 optUpcall: { $$.fd.uc = notUpcall; $$.fd.virtual_f = 0; }
55 | tVIRTUAL { $$.fd.uc = notUpcallAsync; $$.fd.virtual_f = 1;}
56 | tASYNC { $$.fd.uc = notUpcallAsync; $$.fd.virtual_f = 0;}
57 | tVIRTUAL tASYNC { $$.fd.uc = notUpcallAsync; $$.fd.virtual_f = 1;}
58 | tUPCALL { $$.fd.uc = syncUpcall; $$.fd.virtual_f = 0;}
59 | tVIRTUAL tUPCALL {$$.fd.uc = syncUpcall; $$.fd.virtual_f = 1; }
60 | tUPCALL tASYNC { $$.fd.uc = asyncUpcall; $$.fd.virtual_f = 0;}
61 | tVIRTUAL tUPCALL tASYNC { $$.fd.uc = asyncUpcall; $$.fd.virtual_f = 1;}
63 definition: optUpcall typeName pointers tIDENT tLPAREN arglist tRPAREN tSEMI {
67 List <argument *> lp, args;
69 /* reverse arg list */
70 for (lp = *$6.args; *lp; lp++) {
75 malloc(strlen($2.td.cp) + 1 + ($3.cl ? $3.cl->count() : 0));
76 strcpy(retType, $2.cp);
78 for (cl = *$3.cl; *cl; cl++) strcat(retType, "*");
80 tf = new remoteFunc(currentInterface, $3.cl, $4.cp, retType,
81 args, $1.fd.uc, $1.fd.virtual_f, $2.td.structs);
82 currentInterface->newMethod(tf);
88 | tCMEMBER tIDENT pointers tIDENT tSEMI {
89 addCMember ($2.cp, $4.cp, $3.cl); }
90 | tSMEMBER typeName pointers tIDENT tSEMI {
91 addSMember ($2.cp, $4.cp, $3.cl);}
93 typeSpec: tTYPEDEF tSTRUCT tLBLOCK fieldDeclList tRBLOCK tIDENT tSEMI {
95 List<field *> lp, fields;
97 /* reverse field list */
98 for (lp = *$4.fields; *lp; lp++) {
101 s = new typeDefn($6.cp, fields);
106 fieldDeclList: { $$.fields = new List<field*>; }
107 | fieldDeclList fieldDecl { $1.fields->add($2.fld); }
110 // note - $$.td.mallocs will not have any effect for thread code
111 // td.mallocs -> type will malloc memory
112 // td.struct -> type is a struct
114 if (!(foundType = types.find($1.cp)) && !generateTHREAD) {
116 sprintf(str, "unknown type %s", $1.cp);
122 if (generateTHREAD || (!strcmp("String", $1.cp)))
124 else if (foundType->userDefined == TRUE)
131 extern char *findAndAddArrayType(char*);
133 if (!types.find($2.cp) && !generateTHREAD) {
135 sprintf(str, "unknown type %s", $2.cp);
138 $$.td.cp = findAndAddArrayType($2.cp);
144 fieldDecl: typeName tIDENT tSEMI {
145 $$.fld = new field($1.td.cp, $2.cp);
149 pointers: { $$.cl = new List<char*>; }
150 | pointers tSTAR { $1.cl->add("*"); $$.cl = $1.cl; }
153 argument: typeName pointers tIDENT {
154 $$.arg = new argument($1.td.cp, $3.cp, $2.cl, $1.td.mallocs);
156 | typeName pointers {
157 $$.arg = new argument($1.td.cp,currentInterface->genVariable(), $2.cl, $1.td.mallocs);
161 nonEmptyArg: argument {
162 $$.args = new(List<argument*>);
163 $$.args->add($1.arg);
165 | nonEmptyArg tCOMMA argument {
166 $1.args->add($3.arg);
170 arglist: { $$.args = new(List<argument*>); }
171 | nonEmptyArg { $$.args = $1.args; }