mes.c: display, newline: take optional port; add write-char, read hex #xXX.
[mes.git] / cgram-ll1
1 ; Author: Mohd Hanafiah Abdullah (napi@cs.indiana.edu or napi@ms.mimos.my)
2 ; Please report any bugs that you find.  Thanks.
3 ;
4 ; ANSI C LL(k) GRAMMAR (1 <= k <= 2)
5 ;
6 ; THE TERMINALS
7 ;
8 ; "identifier" "octal_constant" "hex_constant" "decimal_constant"
9 ; "float_constant" "char_constant" "string_literal" "sizeof"
10 ; "->" "++" "--" "<<" ">>" "<=" ">=" "==" "!="
11 ; "&&" "||" "*=" "/=" "%=" "+="
12 ; "-=" "<<=" ">>=" "&="
13 ; "^=" "|="
14
15 ; "typedef" "extern" "static" "auto" "register"
16 ; "char" "short" "int" "long" "signed" "unsigned" "float" "double"
17 ; "const" "volatile" "void"
18 ; "struct" "union" "enum" "..."
19
20 ; "case" "default" "if" "else" "switch" "while" "do" "for" "goto"
21 ; "continue" "break" "return"
22 ;---------------------------------------------------------------------------
23
24 (define g
25         '((primary_expr
26                 ("identifier")
27                 ("octal_constant")
28                 ("hex_constant")
29                 ("decimal_constant")
30                 ("float_constant")
31                 ("char_constant")
32                 ("string_literal")
33                 ("(" expr ")"))
34
35         (postfix_expr
36                 (primary_expr postfix_exprP))
37
38         (postfix_exprP
39                 ("[" expr "]" postfix_exprP)
40                 ("(" fact_postfix_exprP)
41                 ("." "identifier" postfix_exprP)
42                 ("->" "identifier" postfix_exprP)
43                 ("++" postfix_exprP)
44                 ("--" postfix_exprP)
45                 ())
46
47         (fact_postfix_exprP
48                 (argument_expr_list ")" postfix_exprP)
49                 (")" postfix_exprP))
50
51         (argument_expr_list
52                 (assignment_expr argument_expr_listP))
53
54         (argument_expr_listP
55                 ("," assignment_expr argument_expr_listP)
56                 ())
57
58         (unary_expr
59                 (postfix_expr)
60                 ("++" unary_expr)
61                 ("--" unary_expr)
62                 (unary_operator cast_expr)
63                 ("sizeof" fact_unary_expr))
64
65         (fact_unary_expr
66                 ("identifier" postfix_exprP)
67                 ("octal_constant" postfix_exprP)
68                 ("hex_constant" postfix_exprP)
69                 ("decimal_constant" postfix_exprP)
70                 ("float_constant" postfix_exprP)
71                 ("char_constant" postfix_exprP)
72                 ("string_literal" postfix_exprP)
73                 ("++" unary_expr)
74                 ("--" unary_expr)
75                 (unary_operator cast_expr)
76                 ("sizeof" fact_unary_expr)
77                 ("(" fact_fact_unary_expr))
78
79         (fact_fact_unary_expr
80                 (expr ")" postfix_exprP)
81                 (type_name ")"))
82
83         (unary_operator
84                 ("&")
85                 ("*")
86                 ("+")
87                 ("-")
88                 ("~")
89                 ("!"))
90
91         (cast_expr
92                 ("identifier" postfix_exprP)
93                 ("octal_constant" postfix_exprP)
94                 ("hex_constant" postfix_exprP)
95                 ("decimal_constant" postfix_exprP)
96                 ("float_constant" postfix_exprP)
97                 ("char_constant" postfix_exprP)
98                 ("string_literal" postfix_exprP)
99                 ("++" unary_expr)
100                 ("--" unary_expr)
101                 (unary_operator cast_expr)
102                 ("sizeof" fact_unary_expr)
103                 ("(" fact_cast_expr))
104
105         (fact_cast_expr
106                 (expr ")" postfix_exprP)
107                 (type_name ")" cast_expr))
108
109         (multiplicative_expr
110                 (cast_expr multiplicative_exprP))
111
112         (multiplicative_exprP
113                 ("*" cast_expr multiplicative_exprP)
114                 ("/" cast_expr multiplicative_exprP)
115                 ("%" cast_expr multiplicative_exprP)
116                 ())
117
118         (additive_expr
119                 (multiplicative_expr additive_exprP))
120
121         (additive_exprP
122                 ("+" multiplicative_expr additive_exprP)
123                 ("-" multiplicative_expr additive_exprP)
124                 ())
125
126         (shift_expr
127                 (additive_expr shift_exprP))
128
129         (shift_exprP
130                 ("<<" additive_expr shift_exprP)
131                 (">>" additive_expr shift_exprP)
132                 ())
133
134         (relational_expr
135                 (shift_expr relational_exprP))
136
137         (relational_exprP
138                 ("<" shift_expr relational_exprP)
139                 (">" shift_expr relational_exprP)
140                 ("<=" shift_expr relational_exprP)
141                 (">=" shift_expr relational_exprP)
142                 ())
143
144         (equality_expr
145                 (relational_expr equality_exprP))
146
147         (equality_exprP
148                 ("==" relational_expr equality_exprP)
149                 ("!=" relational_expr equality_exprP)
150                 ())
151
152         (and_expr
153                 (equality_expr and_exprP))
154
155         (and_exprP
156                 ("&" equality_expr and_exprP)
157                 ())
158
159         (exclusive_or_expr
160                 (and_expr exclusive_or_exprP))
161
162         (exclusive_or_exprP
163                 ("^" and_expr exclusive_or_exprP)
164                 ())
165
166         (inclusive_or_expr
167                 (exclusive_or_expr inclusive_or_exprP))
168
169         (inclusive_or_exprP
170                 ("|" exclusive_or_expr inclusive_or_exprP)
171                 ())
172
173         (logical_and_expr
174                 (inclusive_or_expr logical_and_exprP))
175
176         (logical_and_exprP
177                 ("&&" inclusive_or_expr logical_and_exprP)
178                 ())
179
180         (logical_or_expr
181                 (logical_and_expr logical_or_exprP))
182
183         (logical_or_exprP
184                 ("||" logical_and_expr logical_or_exprP)
185                 ())
186
187         (conditional_expr
188                 (logical_or_expr fact_conditional_expr))
189
190         (fact_conditional_expr
191                 ("?" expr ":" conditional_expr)
192                 ())
193
194         (assignment_expr
195                 (conditional_expr fact_assignment_expr))
196
197         (fact_assignment_expr
198                 (assignment_operator assignment_expr)
199                 ())
200
201         (assignment_operator
202                 ("=")
203                 ("*=")
204                 ("/=")
205                 ("%=")
206                 ("+=")
207                 ("-=")
208                 ("<<=")
209                 (">>=")
210                 ("&=")
211                 ("^=")
212                 ("|="))
213
214         (OPT_EXPR
215                 (expr)
216                 ())
217
218         (expr
219                 (assignment_expr exprP))
220
221         (exprP
222                 ("," assignment_expr exprP)
223                 ())
224
225         (constant_expr
226                 (conditional_expr))
227
228         (declaration
229                 (declaration_specifiers fact_declaration))
230
231         (fact_declaration
232                 (init_declarator_list ";")
233                 (";"))
234
235         (declaration_specifiers
236                 (storage_class_specifier fact_declaration_specifiers1)
237                 (type_specifier fact_declaration_specifiers2)
238                 (type_qualifier fact_declaration_specifiers3))
239
240         (fact_declaration_specifiers1
241                 (declaration_specifiers)
242                 ())
243
244         (fact_declaration_specifiers2
245                 (declaration_specifiers)
246                 ())
247
248         (fact_declaration_specifiers3
249                 (declaration_specifiers)
250                 ())
251
252         (init_declarator_list
253                 (init_declarator init_declarator_listP))
254
255         (init_declarator_listP
256                 ("," init_declarator init_declarator_listP)
257                 ())
258
259         (init_declarator
260                 (declarator fact_init_declarator))
261
262         (fact_init_declarator
263                 ("=" initializer)
264                 ())
265
266         (storage_class_specifier
267                 ("typedef")
268                 ("extern")
269                 ("static")
270                 ("auto")
271                 ("register"))
272
273         (type_specifier
274                 ("void")
275                 ("char")
276                 ("short")
277                 ("int")
278                 ("long")
279                 ("float")
280                 ("double")
281                 ("signed")
282                 ("unsigned")
283                 (struct_or_union_specifier)
284                 (enum_specifier)
285                 (typedef_name))
286
287         (struct_or_union_specifier
288                 (struct_or_union fact_struct_or_union_specifier))
289
290         (fact_struct_or_union_specifier
291                 ("{" struct_declaration_list "}")
292                 ("identifier" fact_fact_struct_or_union_specifier))
293
294         (fact_fact_struct_or_union_specifier
295                 ("{" struct_declaration_list "}")
296                 ())
297
298         (struct_or_union
299                 ("struct")
300                 ("union"))
301
302         (struct_declaration_list
303                 (struct_declaration struct_declaration_listP))
304
305         (struct_declaration_listP
306                 (struct_declaration struct_declaration_listP)
307                 ())
308
309         (struct_declaration
310                 (specifier_qualifier_list struct_declarator_list ";"))
311
312         (specifier_qualifier_list
313                 (type_specifier fact_specifier_qualifier_list1)
314                 (type_qualifier fact_specifier_qualifier_list2))
315
316         (fact_specifier_qualifier_list1
317                 (specifier_qualifier_list)
318                 ())
319
320         (fact_specifier_qualifier_list2
321                 (specifier_qualifier_list)
322                 ())
323
324         (struct_declarator_list
325                 (struct_declarator struct_declarator_listP))
326
327         (struct_declarator_listP
328                 ("," struct_declarator struct_declarator_listP)
329                 ())
330
331         (struct_declarator
332                 (declarator fact_struct_declarator)
333                 (":" constant_expr))
334
335         (fact_struct_declarator
336                 (":" constant_expr)
337                 ())
338
339         (enum_specifier
340                 ("enum" fact_enum_specifier))
341
342         (fact_enum_specifier
343                 ("{" enumerator_list "}")
344                 ("identifier" fact_fact_enum_specifier))
345
346         (fact_fact_enum_specifier
347                 ("{" enumerator_list "}")
348                 ())
349
350         (enumerator_list
351                 (enumerator enumerator_listP))
352
353         (enumerator_listP
354                 ("," enumerator enumerator_listP)
355                 ())
356
357         (enumerator
358                 ("identifier" fact_enumerator))
359
360         (fact_enumerator
361                 ("=" constant_expr)
362                 ())
363
364         (type_qualifier
365                 ("const")
366                 ("volatile"))
367
368         (declarator
369                 (pointer direct_declarator)
370                 (direct_declarator))
371
372         (direct_declarator
373                 ("identifier" direct_declaratorP)
374                 ("(" declarator ")" direct_declaratorP))
375
376         (direct_declaratorP
377                 ("[" fact_direct_declaratorP1)
378                 ("(" fact_direct_declaratorP2)
379                 ())
380
381         (fact_direct_declaratorP1
382                 (constant_expr "]" direct_declaratorP)
383                 ("]" direct_declaratorP))
384
385         (fact_direct_declaratorP2
386                 (parameter_type_list ")" direct_declaratorP)
387                 (identifier_list ")" direct_declaratorP)
388                 (")" direct_declaratorP))
389
390         (pointer
391                 ("*" fact_pointer))
392
393         (fact_pointer
394                 (type_qualifier_list fact_fact_pointer)
395                 (pointer)
396                 ())
397
398         (fact_fact_pointer
399                 (pointer)
400                 ())
401
402         (type_qualifier_list
403                 (type_qualifier type_qualifier_listP))
404
405         (type_qualifier_listP
406                 (type_qualifier type_qualifier_listP)
407                 ())
408
409         (identifier_list
410                 ("identifier" identifier_listP))
411
412         (identifier_listP
413                 ("," "identifier" identifier_listP)
414                 ())
415
416         (parameter_type_list
417                 (parameter_list fact_parameter_type_list))
418
419         (fact_parameter_type_list
420                 ("," "...")
421                 ())
422
423         (parameter_list
424                 (parameter_declaration parameter_listP))
425
426         (parameter_listP
427                 ("," parameter_declaration parameter_listP)
428                 ())
429
430         (parameter_declaration
431                 (declaration_specifiers fact_parameter_declaration))
432
433         (fact_parameter_declaration
434                 (modified_declarator)
435                 ())
436
437         (modified_declarator
438                 (pointer fact_modified_declarator)
439                 (direct_modified_declarator))
440
441         (fact_modified_declarator
442                 (direct_modified_declarator)
443                 ())
444
445         (direct_modified_declarator
446                 ("identifier" direct_modified_declaratorP)
447                 ("[" fact_direct_modified_declarator1)
448                 ("(" fact_direct_modified_declarator2))
449
450         (fact_direct_modified_declarator1
451                 (constant_expr  "]" direct_modified_declaratorP)
452                 ("]" direct_modified_declaratorP))
453
454         (fact_direct_modified_declarator2
455                 (modified_declarator ")" direct_modified_declaratorP)
456                 (parameter_type_list ")" direct_modified_declaratorP)
457                 (")" direct_modified_declaratorP))
458
459         (direct_modified_declaratorP
460                 ("[" fact_direct_modified_declaratorP1)
461                 ("(" fact_direct_modified_declaratorP2)
462                 ())
463
464         (fact_direct_modified_declaratorP1
465                 (constant_expr  "]" direct_modified_declaratorP)
466                 ("]" direct_modified_declaratorP))
467
468         (fact_direct_modified_declaratorP2
469                 (parameter_type_list ")" direct_modified_declaratorP)
470                 (")" direct_modified_declaratorP))
471
472         (type_name
473                 (specifier_qualifier_list fact_type_name))
474
475         (fact_type_name
476                 (abstract_declarator)
477                 ())
478
479         (abstract_declarator
480                 (pointer fact_abstract_declarator)
481                 (direct_abstract_declarator))
482
483         (fact_abstract_declarator
484                 (direct_abstract_declarator)
485                 ())
486
487         (direct_abstract_declarator
488                 ("[" fact_direct_abstract_declarator1)
489                 ("(" fact_direct_abstract_declarator2))
490
491         (fact_direct_abstract_declarator1
492                 (constant_expr "]" direct_abstract_declaratorP)
493                 ("]" direct_abstract_declaratorP))
494
495         (fact_direct_abstract_declarator2
496                 (abstract_declarator ")" direct_abstract_declaratorP)
497                 (parameter_type_list ")" direct_abstract_declaratorP)
498                 (")" direct_abstract_declaratorP))
499
500         (direct_abstract_declaratorP
501                 ("[" fact_direct_abstract_declaratorP1)
502                 ("(" fact_direct_abstract_declaratorP2)
503                 ())
504
505         (fact_direct_abstract_declaratorP1
506                 (constant_expr "]" direct_abstract_declaratorP)
507                 ("]" direct_abstract_declaratorP))
508
509         (fact_direct_abstract_declaratorP2
510                 (parameter_type_list ")" direct_abstract_declaratorP)
511                 (")" direct_abstract_declaratorP))
512
513         (typedef_name
514                 ("identifier"))
515
516         (initializer
517                 (assignment_expr)
518                 ("{" initializer_list fact_initializer))
519
520         (fact_initializer
521                 ("}")
522                 ("," "}"))
523
524         (initializer_list
525                 (initializer initializer_listP))
526
527         (initializer_listP
528                 ("," initializer initializer_listP)
529                 ())
530
531         (statement
532                 (labeled_statement)
533                 (compound_statement)
534                 (expression_statement)
535                 (selection_statement)
536                 (iteration_statement)
537                 (jump_statement))
538
539         (labeled_statement
540                 ("identifier" ":" statement)
541                 ("case" constant_expr ":" statement)
542                 ("default" ":" statement))
543
544         (compound_statement
545                 ("{" fact_compound_statement))
546
547         (fact_compound_statement
548                 (declaration_list fact_fact_compound_statement)
549                 (statement_list "}")
550                 ("}"))
551
552         (fact_fact_compound_statement
553                 (statement_list "}")
554                 ("}"))
555
556         (declaration_list
557                 (declaration declaration_listP))
558
559         (declaration_listP
560                 (declaration declaration_listP)
561                 ())
562
563         (statement_list
564                 (statement statement_listP))
565
566         (statement_listP
567                 (statement statement_listP)
568                 ())
569
570         (expression_statement
571                 (expr ";")
572                 (";"))
573
574         (selection_statement
575                 ("if" "(" expr ")" statement fact_selection_statement)
576                 ("switch" "(" expr ")" statement))
577
578         (fact_selection_statement
579                 ("else" statement)
580                 ())
581
582         (iteration_statement
583                 ("while" "(" expr ")" statement)
584                 ("do" statement "while" "(" expr ")" ";")
585                 ("for" "(" OPT_EXPR ";" OPT_EXPR ";" OPT_EXPR ")" statement))
586
587         (jump_statement
588                 ("goto" "identifier" ";")
589                 ("continue" ";")
590                 ("break" ";")
591                 ("return" fact_jump_statement))
592
593         (fact_jump_statement
594                 (";")
595                 (expr ";"))
596
597         (translation_unit
598                 (external_declaration translation_unitP))
599
600         (translation_unitP
601                 (external_declaration translation_unitP)
602                 ())
603
604         (external_declaration
605                 (arbitrary_declaration))
606
607         (OPT_DECLARATION_LIST
608                 (declaration_list)
609                 ())
610
611         (arbitrary_declaration
612                 (declaration_specifiers fact_arbitrary_declaration)
613                 (declarator OPT_DECLARATION_LIST compound_statement))
614
615         (fact_arbitrary_declaration
616                 (choice1)
617                 (";"))
618
619         (choice1
620                 (init_declarator fact_choice1))
621
622         (fact_choice1
623                 ("," choice1)
624                 (";")
625                 (OPT_DECLARATION_LIST compound_statement))
626 ))
627
628 ------------------------------Cut Here---------------------------------------
629 ; f-f-d.s
630 ;
631 ; Computation of the LL(1) condition, LL(1) director sets,
632 ; and FIRST and FOLLOW sets.
633 ;
634 ; Grammars are represented as a list of entries, where each
635 ; entry is a list giving the productions for a nonterminal.
636 ; The first entry in the grammar must be for the start symbol.
637 ; The car of an entry is the nonterminal; the cdr is a list
638 ; of productions.  Each production is a list of grammar symbols
639 ; giving the right hand side for the production; the empty string
640 ; is represented by the empty list.
641 ; A nonterminal is represented as a Scheme symbol.
642 ; A terminal is represented as a Scheme string.
643 ;
644 ; Example:
645 ;
646 ;  (define g
647 ;    '((S ("id" ":=" E "\;")
648 ;         ("while" E S)
649 ;         ("do" S A "od"))
650 ;      (A ()
651 ;         (S A))
652 ;      (E (T E'))
653 ;      (E' () ("+" T E') ("-" T E'))
654 ;      (T (F T'))
655 ;      (T' () ("*" F T') ("/" F T'))
656 ;      (F ("id") ("(" E ")"))))
657
658 ; Given a grammar, returns #t if it is LL(1), else returns #f.
659
660 (define (LL1? g)
661   (define (loop dsets)
662     (cond ((null? dsets) #t)
663           ((disjoint? (cdr (car dsets))) (loop (cdr dsets)))
664           (else (display "Failure of LL(1) condition ")
665                 (write (car dsets))
666                 (newline)
667                 (loop (cdr dsets)))))
668   (define (disjoint? sets)
669     (cond ((null? sets) #t)
670           ((null? (car sets)) (disjoint? (cdr sets)))
671           ((member-remaining-sets? (caar sets) (cdr sets))
672            #f)
673           (else (disjoint? (cons (cdr (car sets)) (cdr sets))))))
674   (define (member-remaining-sets? x sets)
675     (cond ((null? sets) #f)
676           ((member x (car sets)) #t)
677           (else (member-remaining-sets? x (cdr sets)))))
678   (loop (director-sets g)))
679
680 ; Given a grammar, returns the director sets for each production.
681 ; In a director set, the end of file token is represented as the
682 ; Scheme symbol $.
683
684 (define (director-sets g)
685   (let ((follows (follow-sets g)))
686     (map (lambda (p)
687            (let ((lhs (car p))
688                  (alternatives (cdr p)))
689              (cons lhs
690                    (map (lambda (rhs)
691                           (let ((f (first rhs g '())))
692                             (if (member "" f)
693                                 (union (lookup lhs follows)
694                                        (remove "" f))
695                                 f)))
696                         alternatives))))
697          g)))
698
699 ; Given a string of grammar symbols, a grammar, and a list of nonterminals
700 ; that have appeared in the leftmost position during the recursive
701 ; computation of FIRST(s), returns FIRST(s).
702 ; In the output, the empty string is represented as the Scheme string "".
703 ; Prints a warning message if left recursion is detected.
704
705 (define (first s g recursion)
706   (cond ((null? s) '(""))
707         ((memq (car s) recursion)
708          (display "Left recursion for ")
709          (write (car s))
710          (newline)
711          '())
712         ((and (null? (cdr s)) (string? (car s))) s)
713         ((and (null? (cdr s)) (symbol? (car s)))
714          (let ((p (assoc (car s) g))
715                (newrecursion (cons (car s) recursion)))
716            (cond ((not p)
717                   (error "No production for " (car s)))
718                  (else (apply union
719                               (map (lambda (s) (first s g newrecursion))
720                                    (cdr p)))))))
721         (else (let ((x (first (list (car s)) g recursion)))
722                 (if (member "" x)
723                     (append (remove "" x)
724                             (first (cdr s) g recursion))
725                     x)))))
726
727 ; Given a grammar g, returns FOLLOW(g).
728 ; In the output, the end of file token is represented as the Scheme
729 ; symbol $.
730 ; Warning messages will be printed if left recursion is detected.
731
732 (define (follow-sets g)
733   
734   ; Uses a relaxation algorithm.
735   
736   (define (loop g table)
737     (let* ((new (map (lambda (x) (cons x (fol x g table)))
738                      (map car g)))
739            (new (cons (cons (caar new) (union '($) (cdar new)))
740                       (cdr new))))
741       (if (equal-table? table new)
742           table
743           (loop g new))))
744   
745   ; Given a nonterminal, a grammar, and a table giving
746   ; preliminary follow sets for all nonterminals, returns
747   ; the next approximation to the follow set for the given
748   ; nonterminal.
749   
750   (define (fol x g t)
751     (define (fol-production p)
752       (let ((lhs (car p))
753             (alternatives (cdr p)))
754         (do ((l alternatives (cdr l))
755              (f '() (union (fol-alternative x (car l)) f)))
756             ((null? l)
757              (if (member "" f)
758                  (union (lookup lhs t)
759                         (remove "" f))
760                  f)))))
761     (define (fol-alternative x rhs)
762       (cond ((null? rhs) '())
763             ((eq? x (car rhs))
764              (union (first (cdr rhs) g '())
765                     (fol-alternative x (cdr rhs))))
766             (else (fol-alternative x (cdr rhs)))))
767     (apply union (map fol-production g)))
768   
769   (loop g
770         (cons (list (caar g) '$)
771               (map (lambda (p) (cons (car p) '()))
772                    (cdr g)))))
773
774 ; Tables represented as association lists using eq? for equality.
775
776 (define (lookup x t)
777   (cdr (assq x t)))
778
779 (define (equal-table? x y)
780   (cond ((and (null? x) (null? y)) #t)
781         ((or (null? x) (null? y)) #f)
782         (else (let ((entry (assoc (caar x) y)))
783                 (if entry
784                     (and (equal-as-sets? (cdr (car x)) (cdr entry))
785                          (equal-table? (cdr x) (remove entry y)))
786                     #f)))))
787
788 ; Sets represented as lists.
789
790 (define (equal-as-sets? x y)
791   (and (every? (lambda (a) (member a y)) x)
792        (every? (lambda (a) (member a x)) y)))
793
794 (define (union . args)
795   (define (union2 x y)
796     (cond ((null? x) y)
797           ((member (car x) y)
798            (union (cdr x) y))
799           (else (cons (car x)
800                       (union (cdr x) y)))))
801   (cond ((null? args) '())
802         ((null? (cdr args)) (car args))
803         ((null? (cddr args)) (union2 (car args) (cadr args)))
804         (else (union2 (union2 (car args) (cadr args))
805                       (apply union (cddr args))))))
806
807 (define (every? p? l)
808   (cond ((null? l) #t)
809         ((p? (car l)) (every? p? (cdr l)))
810         (else #f)))
811
812  (define remove
813    (lambda (item ls)
814     (cond
815        ((null? ls) '())
816        ((equal? (car ls) item) (remove item (cdr ls)))
817        (else (cons (car ls) (remove item (cdr ls)))))))
818  
819   (define pp-director-sets
820     (lambda (g)
821       (pp (director-sets g))))
822     
823   (define pp-follow-sets
824     (lambda (g)
825       (pp (follow-sets g))))