Standardizing RPAL AST’s Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Programming Language Principles Lecture 10.

Slides:



Advertisements
Similar presentations
AST Generation Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Programming Language Concepts Lecture 9.
Advertisements

Getting started with ML ML is a functional programming language. ML is statically typed: The types of literals, values, expressions and functions in a.
Fall Semantics Juan Carlos Guzmán CS 3123 Programming Languages Concepts Southern Polytechnic State University.
The Query Compiler Varun Sud ID: 104. Agenda Parsing  Syntax analysis and Parse Trees.  Grammar for a simple subset of SQL  Base Syntactic Categories.
Lecture 8 Recursively enumerable (r.e.) languages
Slide 1 Chapter 2-b Syntax, Semantics. Slide 2 Syntax, Semantics - Definition The syntax of a programming language is the form of its expressions, statements.
מבוא מורחב - שיעור 81 Lecture 8 Lists and list operations (continue).
Introduction and Paradigms Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Programming Language Principles Lecture 1.
The College of Saint Rose CIS 433 – Programming Languages David Goldschmidt, Ph.D. from Concepts of Programming Languages, 9th edition by Robert W. Sebesta,
Chpater 3. Outline The definition of Syntax The Definition of Semantic Most Common Methods of Describing Syntax.
Attribute Grammars Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Programming Language Principles Lecture 17.
Languages A Language L over a finite alphabet  is a set of strings of characters from the alphabet. Examples are : 1.L = { s | s is a grammatical English.
Programming Language Principles Lecture 26 Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Denotational Semantics.
CS 331, Principles of Programming Languages Chapter 2.
Grammars CPSC 5135.
Chapter Twenty-ThreeModern Programming Languages1 Formal Semantics.
Parsing Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Programming Language Principles Lecture 3.
Lambda Calculus Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Programming Language Principles Lecture 11.
Writing RPAL Programs Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Programming Language Concepts Lecture 13.
CS 331, Principles of Programming Languages Chapter 2.
The RPAL Functional Language Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Programming Language Concepts Lecture 12.
Human and Machine Understanding of normal Language (NL) Character Strings Presented by Peter Tripodes.
Types and Programming Languages
An Attribute Grammar for Tiny Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Programming Language Principles Lecture 18.
C H A P T E R T W O Linking Syntax And Semantics Programming Languages – Principles and Paradigms by Allen Tucker, Robert Noonan.
LECTURE 4 Syntax. SPECIFYING SYNTAX Programming languages must be very well defined – there’s no room for ambiguity. Language designers must use formal.
Programming Language Principles Lecture 32 Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Course Summary.
Overview of Compilation Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Programming Language Principles Lecture 2.
Chomsky Normal Form.
PPL Syntax & Formal Semantics Lecture Notes: Chapter 2.
Programming Language Concepts
Describing Syntax and Semantics
Building AST's for RPAL Programs
System Software Unit-1 (Language Processors) A TOY Compiler
Propositional Calculus: Boolean Functions and Expressions
Tuples Module 11.1 COP4020 – Programming Language Concepts Dr. Manuel E. Bermudez.
Introduction to Parsing (adapted from CS 164 at Berkeley)
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
An Attribute Grammar for Tiny
Introduction to RPAL Module 10.1 COP4020 – Programming Language Concepts Dr. Manuel E. Bermudez.
RPAL Function definitions
Programming Language Principles
The Relational Algebra and Relational Calculus
TaBle-driven LL(1) Parsing
The DSW Algorithm The building block for tree transformations in this algorithm is the rotation There are two types of rotation, left and right, which.
TaBle-driven LL(1) Parsing
CSE 311: Foundations of Computing
COP4020 Programming Language Concepts Dr. Manuel E. Bermudez
Lecture 4: Lexical Analysis & Chomsky Hierarchy
Programming Language Principles
Principles of Programming Languages
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Types and Type Checking (What is it good for?)
Building AST's for RPAL Programs
Programming Language Principles
The RPAL Functional Language
List and list operations (continue).
Recursion and Rpal’s synTax
Operator precedence and AST’s
Recursion and Fixed-Point Theory
Programming Language Principles
Paradigms and paradigm shifts
Optimizations for the CSE Machine
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Operator Precedence and Associativity
Operator Precedence and Associativity
Programming Language Principles
Completing the Physical-Query-Plan and Chapter 16 Summary ( )
Programming Language Concepts
Visual Programming Languages ICS 539 Icon System Visual Languages & Visual Programming, Chapter 1, Editor Chang, 1990 ICS Department KFUPM Sept. 1,
Presentation transcript:

Standardizing RPAL AST’s Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Programming Language Principles Lecture 10

The Semantics of RPAL We use the operational approach: To specify the semantics of a language, we give an OPERATIONAL PROCESS. In contrast, later we will discuss the DENOTATIONAL approach: PL constructs are “denoted” with functions whose behavior specify the meaning of the program.

The RPAL Operational Specification In the case of RPAL, the process is 1.Scan and parse the program, transduce to a tree. 2.Standardize the tree.

The RPAL Operational Specification (cont’d) 3.Flatten the tree into either: a. A lambda expression. b. Control Structures for a machine (more later) Important: RPAL = lambda-calculus + syntactic sugar

Standardizing an RPAL AST "Desugar" the tree. Transform into a binary tree, whose internal nodes are exclusively 'gamma' and 'lambda'. Use the RPAL subtree transformational grammar (pictorial version)

Standardizing 'let' and 'where' See example let gamma where / \ / \ / \ = P => lambda E <= P = / \ / \ / \ X E X P X E

Standardizing 'fcn_form' See example fcn_form = / | \ / \ P V+ E => P +lambda / \ V.E V+ means "one or more", to be repeated likewise on right side. The 'dot' indicates the location of the pattern's repetition.

Standardizing Tuples See example tau => ++gamma | / \ E++ gamma E / \ aug.nil E++ means “two or more” E’s.

Standardizing Multi-Parameter Functions See example lambda => ++lambda / \ / \ V++ E V.E

Standardizing the 'within' See example within => = / \ / \ = = X2 gamma / \ / \ / \ X1 E1 X2 E2 lambda E1 / \ X1 E2

Standardizing Unary and Binary Operators See example Uop => gamma | / \ E Uop E Op => gamma / \ / \ E1 E2 gamma E2 / \ Op E1 Uop in [ not, neg ] Op in [ aug, or, &, +, -, /, **, gr,...]

Standardizing the Operator See => gamma / | \ / \ E1 N E2 gamma E2 / \ N E1

Standardizing Simultaneous Definitions See example and => = | / \ =++, tau / \ | | X E X++ E++

Standardizing Simultaneous Definitions (cont’d) lambda => lambda / \ / \, E Temp ++gamma | / \ X++i lambda gamma / \ / \ X.i.E Temp \

Standardizing the Conditional Operator → => gamma / | \ / \ B T F gamma nil / \ gamma lambda / \ / \ gamma lambda () F / \ / \ Cond B () T Cond = fn B. fn T. fn F. B → T | F Circular semantic definition ! Purpose of lambdas: delay evaluation until one option is discarded

Circular Semantic Definitions K. Goedel's Incompleteness Theorem (1930's): Every logic system is either incomplete or inconsistent. Incomplete is preferable to inconsistent. Inevitable in semantics: look up “building” in Webster’s dictionary. English dictionary is useless to someone who understands no English.

Standardizing 'rec' Will do later rec => = | / \ = X gamma / \ / \ X E Ystar lambda / \ X E

Summary Transform AST into a standardized tree (ST). ST is binary. All internal nodes in the ST are either gamma or lambda. It’s called “desugaring” the program: reducing it to two constructs: function abstraction/definition (lambda), and function application (gamma).

Standardizing RPAL AST’s Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Programming Language Principles Lecture 10