Compiler Design Practical

Verified

Added on  2019/09/18

|3
|732
|581
Practical Assignment
AI Summary
This document presents a solved practical assignment focusing on lexical analysis and parsing within the context of compiler design. The assignment involves processing a GUI description, identifying lexemes (constants, numbers, strings), and demonstrating the parser's behavior by showing entry and exit points for non-terminal symbols. The provided solution meticulously details each lexeme identified during the lexical analysis phase, clearly labeling each as a constant, number, or string. Furthermore, it illustrates the parser's actions by displaying messages indicating entry and exit points for each non-terminal symbol, mirroring the approach described in Sebesta's compiler design textbook. This detailed breakdown makes it easy to follow the process of both lexical analysis and parsing, providing a valuable learning resource for students of compiler design.
Document Page
avoid possible confusions on how the output of this project should look like,
here is the output for the "Calculator" example - the one from the specs:
Enter <gui>
Lexeme (constant): Window
Lexeme (string): Calculator
Lexeme (constant): (
Lexeme (number): 200
Lexeme (constant): ,
Lexeme (number): 200
Lexeme (constant): )
Enter <layout>
Lexeme (constant): Layout
Enter <layout_type>
Lexeme (constant): Flow
Lexeme (constant): (
Lexeme (constant): )
Exit <layout_type>
Lexeme (constant): :
Exit <layout>
Enter <widgets>
Enter <widget>
Lexeme (constant): Textfield
Lexeme (number): 20
Lexeme (constant): ;
Exit <widget>
Enter <widgets>
Enter <widget>
Lexeme (constant): Panel
Enter <layout>
Lexeme (constant): Layout
Enter <layout_type>
Lexeme (constant): Grid
Lexeme (constant): (
Lexeme (number): 4
Lexeme (constant): ,
Lexeme (number): 3
Lexeme (constant): ,
Lexeme (number): 5
Lexeme (constant): ,
Lexeme (number): 5
Lexeme (constant): )
Exit <layout_type>
Lexeme (constant): :
Exit <layout>
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Enter <widgets>
Enter <widget>
Lexeme (constant): Button
Lexeme (string): 7
Lexeme (constant): ;
Exit <widget>
Enter <widgets>
Enter <widget>
Lexeme (constant): Button
Lexeme (string): 8
Lexeme (constant): ;
Exit <widget>
Enter <widgets>
Enter <widget>
Lexeme (constant): Button
Lexeme (string): 9
Lexeme (constant): ;
Exit <widget>
Enter <widgets>
Enter <widget>
Lexeme (constant): Button
Lexeme (string): 4
Lexeme (constant): ;
Exit <widget>
Enter <widgets>
Enter <widget>
Lexeme (constant): Button
Lexeme (string): 5
Lexeme (constant): ;
Exit <widget>
Enter <widgets>
Enter <widget>
Lexeme (constant): Button
Lexeme (string): 6
Lexeme (constant): ;
Exit <widget>
Enter <widgets>
Enter <widget>
Lexeme (constant): Button
Lexeme (string): 1
Lexeme (constant): ;
Exit <widget>
Enter <widgets>
Enter <widget>
Lexeme (constant): Button
Lexeme (string): 2
Document Page
Lexeme (constant): ;
Exit <widget>
Enter <widgets>
Enter <widget>
Lexeme (constant): Button
Lexeme (string): 3
Lexeme (constant): ;
Exit <widget>
Enter <widgets>
Enter <widget>
Lexeme (constant): Label
Lexeme (string):
Lexeme (constant): ;
Exit <widget>
Enter <widgets>
Enter <widget>
Lexeme (constant): Button
Lexeme (string): 0
Lexeme (constant): ;
Exit <widget>
Exit <widgets>
Exit <widgets>
Exit <widgets>
Exit <widgets>
Exit <widgets>
Exit <widgets>
Exit <widgets>
Exit <widgets>
Exit <widgets>
Exit <widgets>
Exit <widgets>
Lexeme (constant): End
Lexeme (constant): ;
Exit <widget>
Exit <widgets>
Exit <widgets>
Lexeme (constant): End
Lexeme (constant): .
Exit <gui>
Please notice the following important aspects:
- each lexeme is clearly identified and displayed, making it easy to follow the lexical analysis.
- for each nonterminal recognized by the parser, two messages are displayed: one when entering
and another one when exiting the function that corresponds to that nonterminal (just like Sebesta
does in his book).
chevron_up_icon
1 out of 3
circle_padding
hide_on_mobile
zoom_out_icon