summaryrefslogtreecommitdiff
path: root/web/yacco2/qa/lr1_tst.lex
blob: 9cd4ce3b31aec620babdc68e6ce68a3d7bf9a2e8 (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
/*
$echo     FILE:	LR1_tst.lex
$echo     My grammar to test out merges.
$echo This grammar tests out mergers against the reduce / reduce states
$echo There are 2 sets of rules RAx and RBx where x is 1 or 2 that produce reduce / reduce
$echo conflict states
$echo Okay
*/
/@
@** |LR1_tst| grammar.\fbreak
This grammar tests out mergers against the reduce / reduce states.
There are 2 sets of rules RAx and RBx where x is 1 or 2 that produce reduce / reduce 
conflict states. 

The objectives are:\fbreak
\INDENT{.3in}{1) is the grammar LR1? which it is}
\INDENT{.3in}{2) proper splitting of conflict states by merging into differenct closure states}
@/
fsm (fsm-id    "lr1_tst.lex",fsm-filename lr1_tst,fsm-namespace NS_lr1_tst
    ,fsm-class Clr1_tst_fsm {
    user-imp-sym
      // test out Clr1\_tst\_fsm fsm user-imp-sym emit code
    *** 
    user-imp-tbl
      // test out Clr1\_tst\_fsm fsm user-imp-tbl emit code
    *** 
    constructor
      // test out Clr1\_tst\_fsm fsm constructor emit code
    *** 
    destructor
      // test out Clr1\_tst\_fsm fsm destructor emit code
    *** 
    failed
      // test out Clr1\_tst\_fsm fsm failed emit code
      return true;
    *** 
    op
      // test out Clr1\_tst\_fsm fsm op emit code
    *** 
    user-declaration
      // test out Clr1\_tst\_fsm fsm user-declaration code
      public:
    *** 
    user-implementation
      // test out Clr1\_tst\_fsm fsm user-implementation code
    *** 
    }
   ,fsm-version "1.0",fsm-date     "12 Nov. 2006"
   ,fsm-debug   "true"
   ,fsm-comments "test out lr1 compatibility against 2 sets of reduce /reduce conflict states")
parallel-parser	
(	
  parallel-thread-function
    TH_lr1_tst
  ***
  parallel-la-boundary
    eolr
  ***
)
@"/usr/local/yacco2/compiler/grammars/yacco2_T_includes.T"
rules
{
  Rlr1_tst(
  
lhs  {
    constructor
      // test out Rlr1\_tst rule constructor emit code
    *** 
    destructor
      // test out Rlr1\_tst rule destructor emit code
    *** 
    op
      // test out Rlr1\_tst rule op emit code
    *** 
    user-declaration
      // test out Rlr1\_tst rule user-declaration code
      public:
    *** 
    user-implementation
      // test out Rlr1\_tst rule user-implementation code
    *** 
    }
  ){ 
      -> u RAabBab eog {
      op
        // test out subrule u RAabBab eog op emit code
      *** 
      }
      -> v RAbaBab eog 
      -> w RAabBba eog 
      -> x RAbaBba eog 
    }
    
  RAabBab(){ 
      -> RAab m 
      -> RBab n 
    }
  RAbaBab(){ 
      -> RAba m 
      -> RBab n 
    }
  RAabBba(){ 
      -> RAab m 
      -> RBba n 
    }
  RAbaBba(){ 
      -> RAba m 
      -> RBba n 
    }
    
  RAab(){ 
      -> RA1 a
      -> RA2 b
    }
  RAba(){ 
      -> RA1 b
      -> RA2 a
    }
  RBab(){ 
      -> RB1 a
      -> RB2 b
    }
  RBba(){ 
      -> RB1 b
      -> RB2 a
    }
  RA1(){ 
      -> a 
    }

  RA2(){ 
      -> a 
    }
  RB1(){ 
      -> b 
    }

  RB2(){ 
      -> b 
    }
    
}	// end of grammar