summaryrefslogtreecommitdiff
path: root/web/yacco2/qa/rule8.dat
blob: a015b11d870464b7528b10683fd4dbc3d2da39d6 (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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
/*
$echo file: rule8.dat
$echo  test: premature closing of rules by extra } 
$echo Error
*/

fsm	
(fsm-id "rule_def_phrase.lex"
,fsm-filename rule_def_phrase
,fsm-namespace NS_rule_def_phrase
,fsm-class Crule_def_phrase{
  user-prefix-declaration
    using namespace NS_yacco2_terminals;
    #include "c:/yacco2/compiler/grammars/ws.h"
    #include "c:/yacco2/compiler/grammars/c_comments.h"
    #include "c:/yacco2/compiler/grammars/identifier.h"
    #include "c:/yacco2/compiler/grammars/c_string.h"
    #include "c:/yacco2/compiler/grammars/terminal_def_directives.h"
    #include "c:/yacco2/compiler/grammars/terminal_def_delabort_tags.h"
    #include "c:/yacco2/compiler/grammars/subrules_phrase.h"
    #include "c:/yacco2/compiler/grammars/rule_lhs_phrase.h"
    #include "c:/yacco2/compiler/cweb/symbol table/yacco2_ste.h"
    #include "c:/yacco2/compiler/grammars/parallel_monitor_phrase.h"
  ***
  user-declaration
    public:
    T_rule_def* rule_def_;
  ***
  constructor
    rule_def_ = 0;
  ***
  destructor
    delete rule_def_; // stop_parse: clean up software dodos
  ***
  op
    if(rule_def_ != 0){
      delete rule_def_;
      rule_def_ = 0;
    }
    rule_def_ = new T_rule_def;
    // due to a compiler bug in the whos who of pc processing
    // which is not linux but win...
    //rule_def_->rc(abs_parser()->start_token(),abs_parser());
///*
    CAbs_lr1_sym* Rc = abs_parser()->start_token();
    rule_def_->tok_co_ords__.external_file_id__ = Rc->external_file_id();
    rule_def_->tok_co_ords__.rc_pos__ = Rc->rc_pos();
    rule_def_->tok_co_ords__.line_no__ = Rc->line_no();
    rule_def_->tok_co_ords__.pos_in_line__ = Rc->pos_in_line();
//*/
  ***
}
,fsm-version "1.0",fsm-date "24 mar 2004",fsm-debug "true"
,fsm-comments "into the valley of ...")
parallel-parser	
(	
  parallel-thread-function
    TH_rule_def_phrase
  ***
  parallel-la-boundary
    eolr
  ***
)
@"/yacco2/compiler/grammars/yacco2_T_includes.T"

rules{
Rrule_def_phrase AD AB(){
  -> Rid Rlint Rad_ab_tags  
         Ropen_par Rlint
             Rrule_parameters
         Rclose_par Rlint 
         Rrule_body
         {
      op
      Crule_def_phrase* fsm = (Crule_def_phrase*)abs_parser()->fsm_tbl();
      // add to global symbol table
      const char* skey = fsm->rule_def_->rule_name()->c_str();
      T_sym_tbl_report_card report_card;
      using namespace yacco2_ste;
      find_sym_in_stbl(&report_card,skey);
      if(report_card.action_ == T_sym_tbl_report_card::fnd){
        if(report_card.sym_entry_->type_ != T_table_entry::rule){
          CAbs_lr1_sym* sym = new LR1_err_stble_has_entry_but_not_a_rule;
          sym->rc(abs_parser()->start_token(),abs_parser());
          RSVP(sym)
          abs_parser()->stop_parse(true); 
          return; 
        }
        if(report_card.sym_entry_->defined_ == true){
          CAbs_lr1_sym* sym = new LR1_err_dup_entry_in_sym_table;
          sym->rc(abs_parser()->start_token(),abs_parser());
          RSVP(sym)
          abs_parser()->stop_parse(true); 
          return; 
        }
        report_card.sym_entry_->defined_ = true;
        RSVP(fsm->rule_def_)
        fsm->rule_def_ = 0;
        return; 
      }

      add_sym_to_stbl
          (&report_card
          ,skey
          ,fsm->rule_def_
          ,T_table_entry::defed
          ,T_table_entry::rule);
      RSVP(fsm->rule_def_)
      fsm->rule_def_ = 0;
    ***
    }	
}

Rid AD AB(
lhs
,parallel-control-monitor{
  arbitrator-code
  ***
  }
){
  ->  ||| identifier NS_identifier::TH_identifier {
      op
        Crule_def_phrase* fsm = (Crule_def_phrase*)abs_parser()->fsm_tbl();
        const char* skey = Sub_rule_1.p2__->identifier()->c_str();
        fsm->rule_def_->rule_name(skey);
        Sub_rule_1.p2__->auto_delete(true);
      ***
      } 
  ->  |.| {
      op
        CAbs_lr1_sym* sym = new LR1_err_no_rule_name_present;
        sym->rc(abs_parser()->current_token(),abs_parser());
        RSVP(sym)
        abs_parser()->stop_parse(true);
      ***
      }
}

Rad_ab_tags AD AB(){
  ->  Rad_ab_tag Rlint  
  ->  Rad_ab_tags Rad_ab_tag Rlint
  ->  |.|  
}

Rad_ab_tag AD AB(
lhs
,parallel-control-monitor{
  arbitrator-code
  ***
  }
){
  ->  ||| "#AD" NS_terminal_def_delabort_tags::TH_terminal_def_delabort_tags {
      op 
        Crule_def_phrase* fsm = (Crule_def_phrase*)abs_parser()->fsm_tbl();
        if(fsm->rule_def_->autodelete() == true){
			CAbs_lr1_sym* sym = new LR1_err_already_defined_AD;
			sym->rc(Sub_rule_1.p2__,abs_parser());
			RSVP(sym)
			abs_parser()->stop_parse(true);
			return;
        }
        fsm->rule_def_->autodelete(true);
      ***
      }
  ->  ||| "#AB" NULL {
      op
        Crule_def_phrase* fsm = (Crule_def_phrase*)abs_parser()->fsm_tbl();
        if(fsm->rule_def_->autoabort() == true){
			CAbs_lr1_sym* sym = new LR1_err_already_defined_AB;
			sym->rc(Sub_rule_2.p2__,abs_parser());
			RSVP(sym)
			abs_parser()->stop_parse(true);
			return;
        }
        fsm->rule_def_->autoabort(true);
      ***
      }
}

Rrule_parameters AD AB(){
  -> 
  -> Rrule_parameter
  -> Rrule_parameters "," Rrule_parameter
}

Rrule_parameter AD AB(){
  -> ||| |+| NULL{
      op
        RSVP(Sub_rule_1.p2__)
        abs_parser()->stop_parse(true);
    ***
  }
  -> Rlhs_phrase Rlint
  -> Rparallel_monitor_phrase Rlint
}

Rlhs_phrase AD AB(
lhs
,parallel-control-monitor{
  arbitrator-code
  ***
  }
){
  -> ||| "rule-lhs-phrase" NS_rule_lhs_phrase::TH_rule_lhs_phrase {
      op
      Crule_def_phrase* fsm = (Crule_def_phrase*)abs_parser()->fsm_tbl();
      fsm->rule_def_->rule_lhs(Sub_rule_1.p2__);
    ***
    }
}

Rparallel_monitor_phrase AD AB(
lhs
,parallel-control-monitor{
  arbitrator-code
  ***
  }
){
  -> ||| "parallel-monitor-phrase" NS_parallel_monitor_phrase::TH_parallel_monitor_phrase {
      op
      Crule_def_phrase* fsm = (Crule_def_phrase*)abs_parser()->fsm_tbl();
      fsm->rule_def_->parallel_mntr(Sub_rule_1.p2__);
    ***
    }
}

Rrule_body AD AB(){
  ->  Ropen_brace Rlint 
        Rsubrules 
      Rclose_brace Rlint
}

Rsubrules AD AB(
lhs
,parallel-control-monitor{
  arbitrator-code
  ***
  }
){
  ->  ||| "subrules-phrase" NS_subrules_phrase::TH_subrules_phrase{
      op
      Crule_def_phrase* fsm = (Crule_def_phrase*)abs_parser()->fsm_tbl();
      fsm->rule_def_->subrules(Sub_rule_1.p2__);
    ***
    }
  -> ||| |+| NULL{
      op
        RSVP(Sub_rule_2.p2__)
        abs_parser()->stop_parse(true);
    ***
  }
  ->  |.| { 
      op
        CAbs_lr1_sym* sym = new LR1_err_no_sub_rule_present;
        sym->rc(abs_parser()->current_token(),abs_parser());
        RSVP(sym)
        abs_parser()->stop_parse(true);
      ***
      }
}

Ropen_par AD AB(){
  ->  |.| { 
      op
        CAbs_lr1_sym* sym = new LR1_err_no_open_parenthesis;
        sym->rc(abs_parser()->current_token(),abs_parser());
        RSVP(sym)
        abs_parser()->stop_parse(true);
      ***
      }
  ->  "("
}

Rclose_par AD AB(){
  ->  |.| {
      op
        CAbs_lr1_sym* sym = new LR1_err_no_close_parenthesis;
        sym->rc(abs_parser()->current_token(),abs_parser());
        RSVP(sym)
        abs_parser()->stop_parse(true);
      ***
      }
  ->  ")"
}

Ropen_brace AD AB(){
  ->  |.| { 
      op
        CAbs_lr1_sym* sym = new LR1_err_no_open_brace;
        sym->rc(abs_parser()->current_token(),abs_parser());
        RSVP(sym)
        abs_parser()->stop_parse(true);
      ***
      }
  ->  "{"
}

Rclose_brace AD AB(){
  ->  |.| { 
      op
        CAbs_lr1_sym* sym = new LR1_err_no_closing_brace;
        sym->rc(abs_parser()->current_token(),abs_parser());
        RSVP(sym)
        abs_parser()->stop_parse(true);
      ***
      }
  }//extra

}//this stops the rules process

Rlint AD AB(){
  -> |.|
  -> Rfluffs |.| 
}

Rfluffs AD AB(){
  ->  Rfluff
  ->  Rfluffs Rfluff
}

Rfluff AD AB(
lhs
,parallel-control-monitor{
  arbitrator-code
  ***
  }
){
  ->  ||| ws NS_ws::TH_ws {
      op
        Sub_rule_1.p2__->auto_delete(true);
      ***
      }
  ->  ||| comment NS_c_comments::TH_c_comments {
      op

        Sub_rule_2.p2__->auto_delete(true);
      ***
      }
  ->  ||| |+| NULL {
      op
        RSVP(Sub_rule_3.p2__)
        abs_parser()->stop_parse(true);
      ***
      }
}
}// end of rules