/[bison]/bison/tests/sets.at
ViewVC logotype

Diff of /bison/tests/sets.at

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by akim, Sat Dec 29 14:16:59 2001 UTC revision 1.8 by akim, Sun Jan 27 13:57:03 2002 UTC
# Line 1  Line 1 
1  # Exercising Bison Grammar Sets.                      -*- Autotest -*-  # Exercising Bison Grammar Sets.                      -*- Autotest -*-
2  # Copyright 2001 Free Software Foundation, Inc.  # Copyright 2001, 2002 Free Software Foundation, Inc.
3    
4  # This program is free software; you can redistribute it and/or modify  # This program is free software; you can redistribute it and/or modify
5  # it under the terms of the GNU General Public License as published by  # it under the terms of the GNU General Public License as published by
# Line 16  Line 16 
16  # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
17  # 02111-1307, USA.  # 02111-1307, USA.
18    
19    # AT_EXTRACT_SETS(INPUT, OUTPUT)
20    # ------------------------------
21    # Extract the information about the grammar sets from a bison
22    # trace output (INPUT), and save it in OUTPUT.
23    # And remember, there is no alternation in portable sed.
24    m4_define([AT_EXTRACT_SETS],
25    [AT_DATA([extract.sed],
26    [[#n
27    /^NULLABLE$/ {
28       :nullable
29       p
30       n
31       /^[  ]*$/! b nullable
32    }
33    /^FIRSTS$/ {
34       :firsts
35       p
36       n
37       /^[  ]*$/! b firsts
38    }
39    /^FDERIVES$/ {
40       :fderives
41       p
42       n
43       /^[  ]*$/! b fderives
44    }
45    /^DERIVES$/ {
46       :derives
47       p
48       n
49       /^[  ]*$/! b derives
50    }
51    ]])
52    AT_CHECK([sed -f extract.sed $1], 0, [stdout])
53    AT_CHECK([mv stdout $2])
54    ])
55    
56    
57    
58  AT_BANNER([[Grammar Sets (Firsts etc.).]])  AT_BANNER([[Grammar Sets (Firsts etc.).]])
59    
60    
# Line 39  e: 'e' | /* Nothing */; Line 78  e: 'e' | /* Nothing */;
78  ]])  ]])
79    
80  AT_CHECK([[bison --trace input.y]], [], [], [stderr])  AT_CHECK([[bison --trace input.y]], [], [], [stderr])
81    AT_EXTRACT_SETS([stderr], [sets])
82  AT_CHECK([[sed 's/[      ]*$//' stderr]], [],  AT_CHECK([[cat sets]], [],
83  [[RITEM  [[DERIVES
   e  $  (rule 0)  
   'e'  (rule 1)  
   (rule 2)  
   
   
 DERIVES  
84          $axiom derives          $axiom derives
85                  1: e $ (rule 0)                  1: e $ (rule 0)
86          e derives          e derives
87                  2: 'e' (rule 1)                  2: 'e' (rule 1)
88                  3: (rule 2)                  3: (rule 2)
   
   
 Entering set_nullable  
89  NULLABLE  NULLABLE
90          $axiom: no          $axiom: no
91          e: yes          e: yes
   
   
 TC: Input BEGIN  
   
    01  
   .--.  
  0| 1|  
  1|  |  
   `--'  
 TC: Input END  
   
 TC: Output BEGIN  
   
    01  
   .--.  
  0| 1|  
  1|  |  
   `--'  
 TC: Output END  
   
92  FIRSTS  FIRSTS
93          $axiom firsts          $axiom firsts
94                  4 ($axiom)                  4 ($axiom)
95                  5 (e)                  5 (e)
96          e firsts          e firsts
97                  5 (e)                  5 (e)
   
   
98  FDERIVES  FDERIVES
99          $axiom derives          $axiom derives
100                  0: e $                  0: e $
# Line 95  FDERIVES Line 103  FDERIVES
103          e derives          e derives
104                  1: 'e'                  1: 'e'
105                  2:                  2:
   
   
 Processing state 0 (reached by $)  
 Closure: input  
   
   
 Closure: output  
    0: . e $  (rule 0)  
    3: . 'e'  (rule 1)  
    5: .  (rule 2)  
   
   
 Entering new_itemsets, state = 0  
 Entering append_states, state = 0  
 Entering get_state, state = 0, symbol = 3 ('e')  
 Entering new_state, state = 0, symbol = 3 ('e')  
 Exiting get_state => 1  
 Entering get_state, state = 0, symbol = 5 (e)  
 Entering new_state, state = 0, symbol = 5 (e)  
 Exiting get_state => 2  
 Processing state 1 (reached by 'e')  
 Closure: input  
    4: .  (rule 1)  
   
   
 Closure: output  
    4: .  (rule 1)  
   
   
 Entering new_itemsets, state = 1  
 Entering append_states, state = 1  
 Processing state 2 (reached by e)  
 Closure: input  
    1: . $  (rule 0)  
   
   
 Closure: output  
    1: . $  (rule 0)  
   
   
 Entering new_itemsets, state = 2  
 Entering append_states, state = 2  
 Entering get_state, state = 2, symbol = 0 ($)  
 Entering new_state, state = 2, symbol = 0 ($)  
 Exiting get_state => 3  
 Processing state 3 (reached by $)  
 Closure: input  
    2: .  (rule 0)  
   
   
 Closure: output  
    2: .  (rule 0)  
   
   
 Entering new_itemsets, state = 3  
 Entering append_states, state = 3  
 transpose: input  
   0:  
   
 transpose: output  
   0:  
   
 Lookaheads: BEGIN  
 State 0: 1 lookaheads  
    on 0 ($) -> rule -4  
    on 1 (error) -> rule -4  
    on 2 ($undefined.) -> rule -4  
    on 3 ('e') -> rule -4  
 State 1: 0 lookaheads  
 State 2: 0 lookaheads  
 State 3: 0 lookaheads  
 Lookaheads: END  
106  ]])  ]])
107    
108  AT_CLEANUP  AT_CLEANUP
# Line 246  TC: Output END Line 182  TC: Output END
182  ]])  ]])
183    
184  AT_CLEANUP  AT_CLEANUP
185    
186    
187    
188    ## -------- ##
189    ## Firsts.  ##
190    ## -------- ##
191    
192    AT_SETUP([Firsts])
193    
194    AT_DATA([input.y],
195    [[%nonassoc '<' '>'
196    %left '+' '-'
197    %right '^' '='
198    %%
199    exp:
200       exp '<' exp
201     | exp '>' exp
202     | exp '+' exp
203     | exp '-' exp
204     | exp '^' exp
205     | exp '=' exp
206     | "exp"
207     ;
208    ]])
209    
210    AT_CHECK([[bison --trace input.y]], [], [], [stderr])
211    AT_EXTRACT_SETS([stderr], [sets])
212    AT_CHECK([[cat sets]], [],
213    [[DERIVES
214            $axiom derives
215                    1: exp $ (rule 0)
216            exp derives
217                    2: exp '<' exp (rule 1)
218                    3: exp '>' exp (rule 2)
219                    4: exp '+' exp (rule 3)
220                    5: exp '-' exp (rule 4)
221                    6: exp '^' exp (rule 5)
222                    7: exp '=' exp (rule 6)
223                    8: "exp" (rule 7)
224    NULLABLE
225            $axiom: no
226            exp: no
227    FIRSTS
228            $axiom firsts
229                    10 ($axiom)
230                    11 (exp)
231            exp firsts
232                    11 (exp)
233    FDERIVES
234            $axiom derives
235                    0: exp $
236                    1: exp '<' exp
237                    2: exp '>' exp
238                    3: exp '+' exp
239                    4: exp '-' exp
240                    5: exp '^' exp
241                    6: exp '=' exp
242                    7: "exp"
243            exp derives
244                    1: exp '<' exp
245                    2: exp '>' exp
246                    3: exp '+' exp
247                    4: exp '-' exp
248                    5: exp '^' exp
249                    6: exp '=' exp
250                    7: "exp"
251    ]])
252    
253    AT_CLEANUP

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26