Abstract

We have encountered grammars a number of times. We started our discussions of what a computation is by looking at grammars. We defined languages by devising grammars for defining them. We translated right-linear grammars into transition graphs and then into VLSI circuits. In this chapter, we study programs for parsing input strings, that is, programs that determine whether a given input string can be derived from a given grammar. In the case of right-linear grammars, we had a severe restriction on the grammar: every rule has a left-hand side of exactly one nonterminal and a right-hand side of a sequence of zero or more terminals followed by at most one nonterminal. This restriction corresponds to finite machines. In this chapter, the restriction is less severe. The left-hand side is still restricted to be one nonterminal but the right-hand side is unrestricted. This class of grammars is called the class of context-free grammars. Later on, we have to impose further restrictions to admit efficient parsing algorithms; in fact, we discuss only one parsing strategy. This strategy is called top-down parsing. We give an implementation in the form of a set of recursive procedures, and then the parsing method is sometimes referred to as parsing by recursive descent. This method is limited to grammars that satisfy the LL(1) condition, which is discussed later. We begin by discussing the parsing method in the context of the domino game, and we have a look at its implementation in the form of a set of recursive procedures. We explore the theoretical limitations, and we discuss ways of improving the practical feasibility of this method.

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call

Disclaimer: All third-party content on this website/platform is and will remain the property of their respective owners and is provided on "as is" basis without any warranties, express or implied. Use of third-party content does not indicate any affiliation, sponsorship with or endorsement by them. Any references to third-party content is to identify the corresponding services and shall be considered fair use under The CopyrightLaw.