5.2 PARSING AND AMBIGUITY
We have so far concentrated on the generative aspects of grammars. Given a grammar G, we studied the set of strings that can be derived using G. In cases of practical applications, we are also concerned with the analytical side of the grammar: Given a string w of terminals, we want to know whether or not w is in L(G). If so, we may want to find a derivation of w. An algorithm that can tell us whether w is in L(G) is a membership algorithm. The term parsing describes finding a sequence of productions by which a w ∈ L(G) is derived.
Parsing and Membership
Given a string w in L(G), we can parse it in a rather obvious fashion: We systematically construct all possible (say, leftmost) derivations and see whether any of them ...
Get An Introduction to Formal Languages and Automata, 7th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.