Context-Sensitive Lexical Problems
Consider the phrase âBrown leaves in the fall.â Itâs ambiguous because there are two interpretations. If weâre talking about trees, the phrase refers to natureâs photosynthesis engine. If, on the other hand, weâre discussing a certain Ms. Jane Brown, the context totally changes the function of those words. âLeavesâ shifts from a noun to a verb.
This situation resembles the problems we solved in âRecognizing Ambiguous Phrasesâ where context-sensitive C++ phrases like T(0) could be function calls or type casts depending on how T was defined elsewhere in the program. Such syntactic ambiguities arose because our C++ lexer sent vague generic ID tokens to the parser. We needed semantic predicates ...
Get The Definitive ANTLR 4 Reference, 2nd 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.