Computer and Information Science Engineering
Copyright By PowCoder代写 加微信 powcoder
|if
BNF for Core
| [
-5 is not a legal
Knowledge check:
Problem with the semantics of
How do you fix it?
BNF for Core (contd.)
PT for a simple program
program int X;
begin X = 25; write X; end
Knowledge check:
Some of these nodes do not contain any useful information
Which ones and why?
Concrete vs. Abstract Parse Trees
program int x; begin X = 25; output X; end
program int X;
begin X = 25; write X; end
Abstract Parse Tree
Knowledge Check:
What if we had declared Y instead of X?
What if we had exchanged the two statements?
BNF is Context-Free: Cannot specify such things as:
Only id’s declared in the
The type of the
Such context-sensitive conditions are still syntactic conditions and can and must be checked before execution
BNF cannot specify run-time requirements:
These must be checked during execution
Knowledge Check:
In languages such as Python, even type-checking has got to be done during execution. Why?
Limitations of BNF
Slide 16 notes
How to do this in pure BNF? Using ε it is easy.
Without it, the number of productions increases quite a bit.
But using ε can cause problems for compilers. In homeworks, exams, etc. you may use it unless I say otherwise.
Relation to book: So far, mostly chapter 1; and 3.1., 3.2, 3.3; rest of chapter 3 not inclded.
We will move to chapter 4; that will lead us to the project.
A lot of this should be familiar from 321 and 625. But going over it again should make it easier to see how it relates to PLs and lang. implementations. The project also has some relation to 560.
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com