Tweaking Source Code
Let’s say we want to tweak some source code, perhaps deleting the method bodies of all methods within a particular class file. We also don’t want to mess up the formatting of the file.
First, let’s see whether we can get away with using simple tools like awk or sed. Unfortunately, these tools aren’t so good at matching patterns across lines and the starting { and ending } are most likely on different lines. Worse, it’s hard to distinguish between the curlies of a method and the curlies of a class body or a statement block. We need context information because those curlies mean different things depending on the surrounding text. The minute we say “context,” we know that purely lexical tools and Pattern 2, LL(1) Recursive-Descent ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access