Upgrade to Pro — share decks privately, control downloads, hide ads and more …

UP Lecture 12

UP Lecture 12

Compilers
Parser III
(202403)

Javier Gonzalez-Sanchez

December 15, 2023
Tweet

More Decks by Javier Gonzalez-Sanchez

Other Decks in Programming

Transcript

  1. Dr. Javier Gonzalez-Sanchez | Compilers | 3 jgs Rules PROGRAM

    BODY ASSIGNMENT VARIABLE WHILE IF RETURN PRINT C EXPRESSION X Y R E A B
  2. Dr. Javier Gonzalez-Sanchez | Compilers | 5 jgs Concepts {

    int a; a = 0xFF + 0b111; while (a != 05) { if (true) { a = 2.5e-1 / 7; } else { a = 'A’; while(true) { } } } print ("hello"); } PREDICTIVE DESCENDENT RECURSIVE PARSER
  3. Dr. Javier Gonzalez-Sanchez | Compilers | 7 jgs What about

    a parser for this § {student: 4} § { student: 4 grade:100 } § { student: 4 grade: { hw1: 100 hw2: 90 } }
  4. Dr. Javier Gonzalez-Sanchez | Compilers | 8 jgs Assignment 2

    | Input Are there syntactical errors? { int x; float x; string x; char x; void x; boolean x; }
  5. Dr. Javier Gonzalez-Sanchez | Compilers | 9 jgs Assignment 2

    | Input Are there syntactical errors? { int x; x = 5; x = 05; x = 0x5ff; x = 5.55; x = "five"; x = ’5'; x = false; }
  6. Dr. Javier Gonzalez-Sanchez | Compilers | 10 jgs Assignment 2

    | Input Are there syntactical errors? { x = "hello" + "world" – 'w' * 5 / 3.4; x = y – hello & 0xffff | 05; x = -7; x = !y; x = (cse340 + cse310) / cse101 ; }
  7. Dr. Javier Gonzalez-Sanchez | Compilers | 11 jgs Assignment 2

    | Input Are there syntactical errors? { float a; x = 0; int x; y = 1 + 1; x = (0b11) +(05 – 0xFF34); while (2 == "hi") { a = 2 > (4 + Y); if (true) { if( 2 + 2 ) {} else {} } } print ("hello" + "world"); }
  8. Dr. Javier Gonzalez-Sanchez | Compilers | 12 jgs Assignment 2

    | Input Are there syntactical errors? { if ( if ( if (x – 3) {} ) ) { print ("hello" + "world"); } if (); if (x > 5); ; :) }
  9. Dr. Javier Gonzalez-Sanchez | Compilers | 14 jgs Review *

    Parser.java is the only file that you are allowed to modify
  10. Dr. Javier Gonzalez-Sanchez | Compilers | 15 jgs Homework public

    void error () { System.out.println(”error”); System.exit(); }
  11. jgs Compilers Javier Gonzalez-Sanchez, Ph.D. [email protected] Spring 2024 Copyright. These

    slides can only be used as study material for the Compilers course at Universidad Panamericana. They cannot be distributed or used for another purpose.