## Constructing Functional Programs for Grammar Analysis Problems (1995)

Venue: | In Conference Record of FPCA '95, SIGPLAN-SIGARCH-WG2.8 Conference on Functional Programming Languages and Computer Architecture |

Citations: | 7 - 3 self |

### BibTeX

@INPROCEEDINGS{Jeuring95constructingfunctional,

author = {Johan Jeuring and Doaitse Swierstra},

title = {Constructing Functional Programs for Grammar Analysis Problems},

booktitle = {In Conference Record of FPCA '95, SIGPLAN-SIGARCH-WG2.8 Conference on Functional Programming Languages and Computer Architecture},

year = {1995},

pages = {259--269}

}

### OpenURL

### Abstract

This paper discusses the derivation of functional programs for grammar analysis problems, such as the Empty problem and the Reachable problem. Grammar analysis problems can be divided into two classes: top-down problems such as Follow and Reachable, which are described in terms of the contexts of nonterminals, and bottom-up problems such as Empty and First, which do not refer to contexts. In a previous paper we derive a program for bottom-up grammar analysis problems. In this paper we derive a program for top-down grammar analysis problems by transforming the specification of an arbitrary top-down problem into a program. The existence of a solution is guaranteed provided some natural conditions are satisfied. Furthermore, we describe a general transformation that applies to both classes of grammar analysis problems. The result of this transformation is a program that avoids unnecessary computations in the computation of a fixed point. Constructor classes, which are used to abstract fr...

### Citations

1310 | The essence of functional programming
- Wadler
(Show Context)
Citation Context ...se equalities can be found in Bird and Wadler [3], or in the Bird-Meertens calculus [1, 12]. An important functional programming construct we use is list-comprehension. For example, ? [(x,y) --- x !- =-=[1,2]-=-, y !- [3,4]] [(1,3),(1,4),(2,3),(2,4)] We will use the following laws for list-comprehensions [21] in some calculations. [t --- t !- ts] = ts (4) [f t --- q] = map f [t --- q] (5) [t --- p,q] = conca... |

1065 |
Introduction to Lattices and Order
- Davey, Priestley
- 2002
(Show Context)
Citation Context ...s can be found in Bird and Wadler [3], or in the Bird-Meertens calculus [1, 12]. An important functional programming construct we use is list-comprehension. For example, ? [(x,y) --- x !- [1,2], y !- =-=[3,4]-=-] [(1,3),(1,4),(2,3),(2,4)] We will use the following laws for list-comprehensions [21] in some calculations. [t --- t !- ts] = ts (4) [f t --- q] = map f [t --- q] (5) [t --- p,q] = concat [[t --- q]... |

458 | Comprehending Monads
- Wadler
- 1990
(Show Context)
Citation Context ... by applying correctness preserving transformations to components of the expression occurring in the specification of the problem. The laws we apply are familiar laws for list-comprehensions (monads) =-=[21]-=-, maps, and foldrs [1, 12]. Sufficient conditions for guaranteeing the existence of a fixed point emerge as a byproduct of this derivation. An important advantage of a derivation of a program is that ... |

308 | A unified approach to global program optimization
- Kildall
- 1973
(Show Context)
Citation Context ...or bottom-up grammar analysis problems, be it much simpler. The solution obtained corresponds to the iterative techniques in program flow analysis [17], and can be traced back among others to Kildall =-=[11]-=-. Furthermore, we apply a general transformation to the resulting fixed point solutions for bottom-up and top-down grammar analysis problems. In a first, naive, formulation of the fixed point computat... |

298 | Functional programming with bananas, lenses, envelopes and barbed wire
- Meijer, Fokkinga, et al.
- 1991
(Show Context)
Citation Context ... in which a constant expression (in our case a constant computation) is moved out of the body of a loop. Two essential ingredients of this transformation are constructor classes [9], and anamorphisms =-=[13]-=-. Since we use constructor classes, we have used Gofer [10] to implement the functions we have derived. Incorporating the functions for solving grammar analysis problems in parser generators such as a... |

215 |
An introduction to the theory of lists
- Bird
- 1987
(Show Context)
Citation Context ...s preserving transformations to components of the expression occurring in the specification of the problem. The laws we apply are familiar laws for list-comprehensions (monads) [21], maps, and foldrs =-=[1, 12]-=-. Sufficient conditions for guaranteeing the existence of a fixed point emerge as a byproduct of this derivation. An important advantage of a derivation of a program is that it is clear why and where ... |

178 | A system of constructor classes: overloading and implicit higher-order polymorphism
- Jones
- 1993
(Show Context)
Citation Context ... to the transformation in which a constant expression (in our case a constant computation) is moved out of the body of a loop. Two essential ingredients of this transformation are constructor classes =-=[9]-=-, and anamorphisms [13]. Since we use constructor classes, we have used Gofer [10] to implement the functions we have derived. Incorporating the functions for solving grammar analysis problems in pars... |

69 |
Program Flow Analysis, Theory and Applications, chapter 4, Flow Analysis and Optimization of LISP-like Structures
- Jones, Muchnick
- 1983
(Show Context)
Citation Context ...roblem. The derivation is similar to the derivation for bottom-up grammar analysis problems, be it much simpler. The solution obtained corresponds to the iterative techniques in program flow analysis =-=[17]-=-, and can be traced back among others to Kildall [11]. Furthermore, we apply a general transformation to the resulting fixed point solutions for bottom-up and top-down grammar analysis problems. In a ... |

43 |
Calculating Compilers
- Meijer
- 1992
(Show Context)
Citation Context ...or the bottom ? of natural numbers, we get, applying the Fixed Point Fusion Theorem, f 0 = ?sf (n+1) = g (f n) ) f infty = ��g Other applications of a calculus of extreme fixed points can be found=-= in [14] and [19-=-] If c is a semilattice, and function g :: c -? c is monotonic, then ��g exists, and ��g = lfp g bottom, where functionslfp is defined by lfp f x = x, f x == x = lfp f (f x), otherwise We have... |

37 | Theories for Algorithm Calculation
- Jeuring
- 1993
(Show Context)
Citation Context ...m is a list catamorphism [13]. For these functions we have to . from = id (13) from . tosid (14) The proofs of these equations are by coinduction, and use properties of anamorphisms [13, 14] and zips =-=[2, 6]-=-. They are omitted for reasons of space. Functions to and from are introduced in the fixed point computation as follows. lfp f x = equality for fixed points (7) firstequal xs where xs = x:map f xs = t... |

18 |
Linguistic Parsing and Program Transformation
- Nederhof
- 1994
(Show Context)
Citation Context ...mine the synthesised attributes upon which an inherited attribute depends (SI). Such problems are called grammar analysis problems. More examples of grammar analysis problems can be found in [16] and =-=[18]-=-. Grammar analysis problems can be divided into two classes:sbottom-up and top-down. The difference between these classes is that the required information for a nonterminal in a top-down problem depen... |

14 |
Algorithmics--towards programming as a mathematical activity
- Meertens
- 1986
(Show Context)
Citation Context ...s preserving transformations to components of the expression occurring in the specification of the problem. The laws we apply are familiar laws for list-comprehensions (monads) [21], maps, and foldrs =-=[1, 12]-=-. Sufficient conditions for guaranteeing the existence of a fixed point emerge as a byproduct of this derivation. An important advantage of a derivation of a program is that it is clear why and where ... |

13 |
Grammar Flow Analysis
- Möncke, Wilhelm
- 1991
(Show Context)
Citation Context ...ly, determine the synthesised attributes upon which an inherited attribute depends (SI). Such problems are called grammar analysis problems. More examples of grammar analysis problems can be found in =-=[16]-=- and [18]. Grammar analysis problems can be divided into two classes:sbottom-up and top-down. The difference between these classes is that the required information for a nonterminal in a top-down prob... |

12 |
Computing with lattices: An application of type classes
- Jones
- 1992
(Show Context)
Citation Context ...ift [a] give two possibilities to implement sets as a semilattice. The difference between these types is that [a] has the empty set as bottom, whereas Lift [a] has a bottom below the empty set. Jones =-=[8]-=- gives a more extensive introduction to computing with lattices. 3.2 CPOs Let b be a subset of a poset. b is said to be directed if every finite subset of b has a lub. A poset a is a complete partial ... |

9 |
Ratatosk -- a parser generator and scanner generator for Gofer. Published on comp.lang.functional
- Mogensen
- 1993
(Show Context)
Citation Context ... used Gofer [10] to implement the functions we have derived. Incorporating the functions for solving grammar analysis problems in parser generators such as a functional version of Yacc [20], Ratatosk =-=[15]-=-, and Happy [5] would reduce the amount of code used in these parser generators. The complete code constructed in this paper is available by ftp from ftp.cs. chalmers.se. The code can be found in the ... |

7 | Bottom-up grammar analysis - a functional formulation
- Jeuring, Swierstra
- 1994
(Show Context)
Citation Context ...d give several solutions, depending on the conditions that are satisfied, for such problems. One of the goals of this paper is to derive the solutions given by Moncke and Wilhelm. In a previous paper =-=[7]-=- we study bottom-up grammar analysis problems. We derive a function of which the fixed point gives the solution of a bottom-up grammar analysis problem. This function is obtained by applying correctne... |

6 |
Yacc in Sasl – an exercise in functional programming
- Jones
- 1985
(Show Context)
Citation Context ...lasses, we have used Gofer [10] to implement the functions we have derived. Incorporating the functions for solving grammar analysis problems in parser generators such as a functional version of Yacc =-=[20]-=-, Ratatosk [15], and Happy [5] would reduce the amount of code used in these parser generators. The complete code constructed in this paper is available by ftp from ftp.cs. chalmers.se. The code can b... |

2 |
Release notes for Gofer 2.28. Included as part of the standard Gofer distribution
- Jones
- 1993
(Show Context)
Citation Context ...putation) is moved out of the body of a loop. Two essential ingredients of this transformation are constructor classes [9], and anamorphisms [13]. Since we use constructor classes, we have used Gofer =-=[10]-=- to implement the functions we have derived. Incorporating the functions for solving grammar analysis problems in parser generators such as a functional version of Yacc [20], Ratatosk [15], and Happy ... |