From d6bd0c0e8e08660606801e846273d4740947d658 Mon Sep 17 00:00:00 2001 From: chatty Date: Mon, 29 Nov 1993 11:08:19 +0000 Subject: Renamed into UchMsgMgr Heavy additions. --- comm/OLD/ReqMgr.y | 103 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 70 insertions(+), 33 deletions(-) (limited to 'comm/OLD/ReqMgr.y') diff --git a/comm/OLD/ReqMgr.y b/comm/OLD/ReqMgr.y index 4c29f00..8c0078f 100644 --- a/comm/OLD/ReqMgr.y +++ b/comm/OLD/ReqMgr.y @@ -34,12 +34,12 @@ static void error (const char*, ...); #include "ReqMgr.h" -static UchReqMgr* CurMgr; -static RequestType* CurRequest; -static CcuListOf * CurFieldList; -static CcuDictionnaryOf Fields (16); +static UchMsgMgr* CurMgr; +static MsgType* CurMsg; +static CcuListOf * CurFieldList; +static CcuDictionnaryOf Fields (16); -static void AddFieldToReq (const char*, const char*, const char*, const char*, const char*); +static void AddFieldToMsg (const char*, const char*, const char*, const char*, const char*); static void AddFieldToList (const char*); %} @@ -49,7 +49,7 @@ static void AddFieldToList (const char*); const char *string; } -%token Y_CLIENT Y_REQUEST Y_YIELDS Y_GETTERS Y_SETTERS Y_CONST +%token Y_SERVICE Y_REQUEST Y_ANSWER Y_EVENT Y_YIELDS Y_GETTERS Y_SETTERS Y_CONST %token Y_ID %type opt_star @@ -61,12 +61,14 @@ file: ; decl: - client + service | request + | answer + | event ; -client: - Y_CLIENT Y_ID ';' +service: + Y_SERVICE Y_ID ';' { CurMgr->SetName ($2); } @@ -75,19 +77,44 @@ client: request: Y_REQUEST Y_ID { - CurRequest = new RequestType ($2); - CurMgr->Add (CurRequest); + CurMsg = new MsgType ($2, MsgType::isRequest); + CurMgr->AddRequest (CurMsg); Fields.Clear (); } - '{' request_entries '}' ';' + msg_body ; -request_entries: +answer: + Y_ANSWER Y_ID + { + CurMsg = new MsgType ($2, MsgType::isAnswer); + CurMgr->AddAnswer (CurMsg); + Fields.Clear (); + } + msg_body + ; + +event: + Y_EVENT Y_ID + { + CurMsg = new MsgType ($2, MsgType::isEvent); + CurMgr->AddEvent (CurMsg); + Fields.Clear (); + } + msg_body + ; + + + msg_body: + '{' msg_entries '}' ';' + ; + +msg_entries: /* empty */ - | request_entries request_entry + | msg_entries msg_entry ; -request_entry: +msg_entry: field | getters | setters @@ -97,11 +124,11 @@ request_entry: field: Y_CONST Y_ID opt_star Y_ID Y_YIELDS Y_ID ';' { - AddFieldToReq ("const", $2, $3, $4, $6); + AddFieldToMsg ("const", $2, $3, $4, $6); } | Y_ID opt_star Y_ID Y_YIELDS Y_ID ';' { - AddFieldToReq (0, $1, $2, $3, $5); + AddFieldToMsg (0, $1, $2, $3, $5); } ; @@ -113,7 +140,7 @@ opt_star: getters: Y_GETTERS { - CurFieldList = &CurRequest->Getters; + CurFieldList = &CurMsg->Getters; } '(' id_list ')' ';' ; @@ -121,7 +148,7 @@ getters: setters: Y_SETTERS { - CurFieldList = &CurRequest->Setters; + CurFieldList = &CurMsg->Setters; } '(' id_list ')' ';' ; @@ -129,14 +156,18 @@ setters: constructor: Y_ID { - if (strcmp ($1, CurRequest->GetName ()) != 0) + if (strcmp ($1, CurMsg->GetName ()) != 0) fprintf (stderr, "unknown name %s in request type %s. Considering as constructor.\n", - $1, CurRequest->GetName ()); - RequestConstructor* c = new RequestConstructor; - CurRequest->AddConstructor (c); + $1, CurMsg->GetName ()); + MsgConstructor* c = new MsgConstructor; + CurMsg->AddConstructor (c); CurFieldList = &c->Params; } '(' id_list ')' ';' + { + if (CurFieldList->IsEmpty ()) + CurMsg->UseDefaultConstructor (); + } ; id_list: @@ -149,32 +180,32 @@ id_list: #include static void -AddFieldToReq (const char* c, const char* t, const char* s, const char* id, const char* impl) +AddFieldToMsg (const char* c, const char* t, const char* s, const char* id, const char* impl) { int found; - CcuHashCellOf * hc = Fields.Add (id, &found); + CcuHashCellOf * hc = Fields.Add (id, &found); if (found) { fprintf (stderr, "warning: duplicate field %s in request %s. Ignoring. \n", - id, CurRequest->GetName ()); + id, CurMsg->GetName ()); } else { char buf [128]; if (c || s) { sprintf (buf, "%s %s %s", (c ? c : ""), t, (s ? s : "")); t = buf; } - RequestField* f = new RequestField (id, t, impl); + MsgField* f = new MsgField (id, t, impl); hc->SetInfo (f); - CurRequest->AddField (f); + CurMsg->AddField (f); } } static void AddFieldToList (const char* name) { - RequestField* f = Fields [name]; + MsgField* f = Fields [name]; if (!f) { fprintf (stderr, "warning: unknown field %s in request %s\n", - name, CurRequest->GetName ()); + name, CurMsg->GetName ()); } else { CurFieldList->Append (f); } @@ -212,12 +243,18 @@ tee (int x) case Y_ID: s = "ID"; break; - case Y_CLIENT: - s = "CLIENT"; + case Y_SERVICE: + s = "SERVICE"; break; case Y_REQUEST: s = "REQUEST"; break; + case Y_ANSWER: + s = "ANSWER"; + break; + case Y_EVENT: + s = "EVENT"; + break; case Y_YIELDS: s = "->"; break; @@ -254,7 +291,7 @@ yywrap () } void -UchReqMgr :: Read (const char* file) +UchMsgMgr :: Read (const char* file) { extern void LexInit (); extern FILE *yyin; -- cgit v1.1