1 / 15

Building AST's for RPAL Programs

Building AST's for RPAL Programs. Programming Language Concepts Lecture 14. Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida. Let's Build a Few Abstract Syntax Trees. Example 1: Factorial, version 3. Example 2: Palindrome. Example 3: Add numbers from list.

ena
Télécharger la présentation

Building AST's for RPAL Programs

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Building AST's for RPAL Programs Programming Language Concepts Lecture 14 Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida

  2. Let's Build a Few Abstract Syntax Trees • Example 1: Factorial, version 3. • Example 2: Palindrome. • Example 3: Add numbers from list. • Example 5: Build tuple of pairs of characters.

  3. Class Project • Build a recursive descent parser for RPAL (gulp!) • If done properly, it's easy. • Need lexical analyzer, to be called repeatedly (important!) by the parser. Avoid scanning the entire input in advance of the parser.

  4. Class Project (cont’d) • Code up one procedure per nonterminal in RPAL's grammar. • Pseudo code for some portions of RPAL’s grammar

  5. Class Project (cont’d) • Implement support module for trees, and stack of trees. • Suggestion: use first-child, next-sibling binary tree representation of n-ary trees (it works!). • Preorder traversal of this tree is the same as for n-ary tree. • Popping n trees from the stack, and building a parent node on top of them, is easy.

  6. Building AST's for RPAL Programs Programming Language Concepts Lecture 14 Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida

More Related