1 June 14, 2022 1 June 14, 2022 June 14, 2022 Azusa, Azusa, CA CA Sheldon X. Liang Ph. D. Computer Science at Computer Science at Azusa Azusa Pacific University Pacific University Azusa Pacific University, Azusa, CA 91702, Tel: (800) 825-5278 Department of Computer Science, http://www.apu.edu/clas/computerscience/ CS400 Compiler Construction CS400 Compiler Construction
21
Embed
1 October 2, 2015 1 October 2, 2015October 2, 2015October 2, 2015 Azusa, CA Sheldon X. Liang Ph. D. Computer Science at Azusa Pacific University Azusa.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
1
April 21, 20231
April 21, 2023April 21, 2023 Azusa, CAAzusa, CA
Sheldon X. Liang Ph. D.
Computer Science at Computer Science at Azusa Pacific UniversityAzusa Pacific University
Azusa Pacific University, Azusa, CA 91702, Tel: (800) 825-5278 Department of Computer Science, http://www.apu.edu/clas/computerscience/
CS400 Compiler ConstructionCS400 Compiler Construction
• One of the major roles of the parser is to produce an intermediate representation (IR) of the source program using syntax-directed translation methods
• Possible IR output:– Abstract syntax trees (ASTs)– Control-flow graphs (CFGs) with triples, three-address
code, or register transfer list notation– WHIRL (SGI Pro64 compiler) has 5 IR levels!
April 21, 20236
Azusa Pacific University, Azusa, CA 91702, Tel: (800) 825-5278 Department of Computer Science, http://www.apu.edu/clas/computerscience/
CS@APU: CS400 Compiler ConstructionCS@APU: CS400 Compiler Construction
where A is a production in the grammar• In addition, we define
is leftmost lm if does not contain a nonterminal is rightmost rm if does not contain a nonterminal– Transitive closure * (zero or more steps)– Positive closure + (one or more steps)
• The language generated by G is defined byL(G) = {w T* | S + w}
April 21, 202313
Azusa Pacific University, Azusa, CA 91702, Tel: (800) 825-5278 Department of Computer Science, http://www.apu.edu/clas/computerscience/
CS@APU: CS400 Compiler ConstructionCS@APU: CS400 Compiler Construction
Azusa Pacific University, Azusa, CA 91702, Tel: (800) 825-5278 Department of Computer Science, http://www.apu.edu/clas/computerscience/
CS@APU: CS400 Compiler ConstructionCS@APU: CS400 Compiler Construction
Avram Noam Chomsky is an American linguist, philosopher,, and lecturer. He is a professor emeritus of linguistics at the MIT. Chomsky is well known in the academic and scientific community as the father of modern linguistics. In the 1950s, Chomsky began developing his theory of generative grammar, which has had a profound influence on linguistics. He established the Chomsky hierarchy, a classification of formal languages in terms of their generative power. His naturalistic approach to the study of language has affected the philosophy of language and mind.
16
April 21, 202316
Azusa Pacific University, Azusa, CA 91702, Tel: (800) 825-5278 Department of Computer Science, http://www.apu.edu/clas/computerscience/
CS@APU: CS400 Compiler ConstructionCS@APU: CS400 Compiler Construction
• A grammar G is said to be– Regular if it is right linear where each production is of the form
A w B or A wor left linear where each production is of the form
A B w or A w– Context free if each production is of the form
A where A N and (NT)*
– Context sensitive if each production is of the form A