CS118 Programming Languages

Lecture 5


Reference

Contents

  1. Review Sentential Form and Canonical Parse
  2. Parse Trees and PFN
  3. Restrictions on CFGs
  4. Probablistic Grammars
  5. Grammar Grammars
  6. Assignments

Sentential Forms (review)

...the intermediate results of parsing

Parse Trees and PFN

...precedence and associativity

The parenthesis-free notation of Lukasiewicz (PFN or reverse Polish) is used in interpreters and some hardware. You can find a reference to it in "Selected Works of Jan Lukasiewicz" (1971). Here is a footnote copied from "Nicod's axion and "generalizing deduction. page 180":

"I came upon the idea of a parenthesis-free notation in 1924. I used that notation for the first time in my article Lukasiewicz(1), p. 610, footnote. See also Lukasiewicz (2) pp. 7 and 38, and Kotarbinski, p. 244."

In fact, Lukasiewicz (1) mentiond above is a lithographed report in Polish.

Restrictions on CFGs

...erasure, circularity, nonterminating and unreachable symbols, ambiguity

Probabilistic Grammars

...each rule has a frequency, can be used to generate random sentences

Grammar Grammars

...non terminals must be described (why not use colors?)

Here is a problem that Doug McIlroy claims dates back to C.Y. Lee and then later Ken Thompson in his Turing lecture. Modify an arbitrary program P so that it prints itself (including the modification) before it executes. One can pose two easier subproblems. (1) P does nothing. (2) P contains no quote marks. And, of course, it matters what P is written in (answers). For more examples, try the quine page.


go to:

CS118
Home Page
CS118
Summary
Previous
Lecture
Next
Lecture