5.1 Implicit Stacking in RDP
If the language can be parsed by an RDP, then a simple method is available to implement many of the semantic analysis operations. The method illustrated here is further used extensively in Chapter 8 on Intermediate Code, for generating the Intermediate representation of the program. Several further examples of implicit stacking in RDP are given.
We shall use the following sub-grammar of an IF-THEN-ELSE construct:
if–stmt : IF logic–expr THEN stmt–list FI
| IF logic–expr THEN stmt–list1 ELSE stmt–list2 FI
;
stmt : basic–stmt
| if–stmt
;
stmt–list : stmt
| stmt–list stmt
;
This grammar may have to be modified depending upon the type of the parser used. The above grammar implies the following source construct and corresponding ...
Get Compilers: Principles and Practice 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.