summaryrefslogtreecommitdiff
path: root/java/src/Svc_Conf.y
blob: a11a18f9af0b678ed3bf3b90254ee71fa73ef809 (plain)
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
package JACE.ServiceConfigurator;

import java.io.*;
import java_cup.runtime.*;
import JACE.OS.*;

parser code {: 
  // Lexical Analyzer
  private Yylex lexer_;

  public void setLexer(Yylex lexer)
    {
      this.lexer_ = lexer;
    }
:};

init with {: 
      try {

	FileInputStream fs = new FileInputStream(new String(ServiceConfig.serviceConfigFile_));

        this.setLexer(new Yylex(fs));

      } catch (FileNotFoundException fnf) {

	ACE.ERROR("File not found: " + fnf);

      } catch (SecurityException se) {

	ACE.ERROR("Security: " + se);
      }
:};

scan with {: return this.lexer_.yylex(); :};

terminal token ACE_DYNAMIC, ACE_STATIC, ACE_SUSPEND, ACE_RESUME, ACE_REMOVE, ACE_STREAM;
terminal token ACE_MODULE_T, ACE_STREAM_T, ACE_SVC_OBJ_T, ACE_ACTIVE, ACE_INACTIVE;
terminal str_token ACE_PATHNAME, ACE_IDENT, ACE_STRING;
terminal token ACE_LPAREN, ACE_RPAREN, ACE_LBRACE, ACE_RBRACE, ACE_STAR, ACE_COLON;
terminal token ACE_USTREAM; 

non terminal AddServiceObjectNode dynamic, svc_location; /* AddServiceObjectNode */
non terminal SuspendNode suspend;  /* SuspendNode */
non terminal ResumeNode resume;  /* ResumeNode */
non terminal RemoveNode remove;  /* RemoveNode */
non terminal ParseNode module_list, stream, svc_config_entry;
non terminal ParseNode svc_config_entries, static;
non terminal java_cup.runtime.str_token stream_modules, module;
non terminal java_cup.runtime.int_token status;
non terminal java_cup.runtime.str_token svc_initializer;
non terminal java_cup.runtime.str_token pathname, parameters_opt;
non terminal java_cup.runtime.str_token stream_ops, type;

start with svc_config_entries;

svc_config_entries ::= svc_config_entry:e1 svc_config_entries
                       {: 
			 if (e1 != null)
			   e1.apply();
                       :}
                       |
                       svc_config_entry:e1
                       {:  
			 if (e1 != null)
			   e1.apply();
		       :}
                       ;

svc_config_entry ::= dynamic
                     {: 
		       /* Empty -- result auto set to dynamic */
		       /* CUP$result = (ParseNode)CUP$stack.elementAt(CUP$top-0); */
		     :}
                     | 
                     static  
                     {: 
		       /* More graceful error system needed here */
		       ACE.ERROR("Not implemented: static service loading"); :}
                     | 
                     suspend
                     {: 
		       /* Empty -- result auto set to suspend */
		       /* CUP$result = (ParseNode)CUP$stack.elementAt(CUP$top-0); */
		     :}
                     | 
                     resume
                     {:  /* Empty -- result auto set to resume */ 
		     :}
                     | 
                     remove
                     {: 

		     :}
                     | 
                     stream
		     {: ACE.ERROR("Not implemented: stream loading"); :}
                     ;

dynamic ::= ACE_DYNAMIC svc_location:e1 parameters_opt:e2
{:
  RESULT.init(e1.name(), e1.locator(), e1.suspended());

  RESULT.params(e2.str_val);
:}
     ;

static ::= ACE_STATIC ACE_IDENT parameters_opt
     ;

suspend ::= ACE_SUSPEND ACE_IDENT:e1
{:
  RESULT.init(e1.str_val);
:}
     ;

resume ::= ACE_RESUME ACE_IDENT:e1
{:
  RESULT.init(e1.str_val);
:}
     ;

remove ::= ACE_REMOVE ACE_IDENT:e1
{:
  RESULT.init(e1.str_val);
:}
     ;

stream ::= ACE_USTREAM stream_ops stream_modules
           |
           ACE_USTREAM ACE_IDENT stream_modules
           ;

stream_ops ::= dynamic
               |
               static
               ;

stream_modules ::= ACE_LBRACE 
                   |
                   module_list ACE_RBRACE
                   ;

module_list ::= module_list module
                {: ACE.ERROR("Not implemented: module manipulation"); :}
                | 
                {: ACE.ERROR("Not implemented: module manipulation"); :}
                ;

module ::= dynamic
           |
           static
           |
           suspend
           | 
           resume
           | 
           remove
           ;

svc_location ::= ACE_IDENT:e1 type:e2 svc_initializer:e3 status:e4
{:
  boolean suspended = false;
  if (e4.int_val == 1)
    suspended = true;

  RESULT.init(e1.str_val, e3.str_val, suspended);
:}
;

status ::= ACE_ACTIVE
           {: RESULT.int_val = 0; :}
           |
           ACE_INACTIVE
           {: RESULT.int_val = 1; :}
           |
           {: // Default case
              RESULT.int_val = 0; :} 
           ;

svc_initializer ::= pathname:e1 ACE_COLON ACE_IDENT:e2
                    {: RESULT.str_val = new String(e1.str_val + ":" + e2.str_val); :}
                    |
                    pathname:e1 ACE_COLON ACE_IDENT:e2 ACE_LPAREN ACE_RPAREN
                    {: RESULT.str_val = new String(e1.str_val + ":" + e2.str_val); :}
                    ;

type ::= ACE_MODULE_T ACE_STAR
         |
         ACE_SVC_OBJ_T ACE_STAR
         {: RESULT.str_val = new String("Service Object"); :}
         |
         ACE_STREAM_T ACE_STAR
         ;

parameters_opt ::= ACE_STRING:e
                   {: RESULT.str_val = new String(e.str_val); :}
                   |
                   ;

pathname ::= ACE_PATHNAME:e
             {: RESULT.str_val = new String(e.str_val); :}
             | 
             ACE_IDENT:e
             {: RESULT.str_val = new String(e.str_val); :}
             ;