Download presentation
Presentation is loading. Please wait.
Published byAnastasia Dorsey Modified over 8 years ago
1
2016/7/9Page 1 Lecture 11: Semester Review COMP3100 Dept. Computer Science and Technology United International College
2
2016/7/92 Introduction Compilation vs. Interpretation Compilation stages
3
2016/7/93 DFA and its equivalents DFA&NFA Definition Accepted string Regular expression Notation Accepted string Convert to NFA and DFA Regular grammar Definition DFA=NFA=Regular expression=Regular grammar
4
2016/7/94 Regular expression->DFA Start with a regular expression. Construct an NFA from it. Use a set of subsets construction to obtain an equivalent DFA. Construct the minimal equivalent DFA.
5
2016/7/95 Convert the following regular expression to a DFA 1(0|1)*101
6
2016/7/96 Construct an NFA from it.
7
2016/7/97 Obtain an equivalent DFA
8
2016/7/98
9
9 Minimization
10
2016/7/910 PDA and its relevant Context free languages Definition PDA Definition Difference between PDA and DFA How does it work? A language is context-free iff a pushdown automata recognizes it Non-deterministic PDA are more powerful than deterministic ones
11
2016/7/911 Parser-Top down parsing Predicts a derivation Matches non-terminal against token observed in input How to parse given a parse table? First set, follow set Parse table construction LL(1) grammar Convert non-LL(1) grammar to LL(1) grammar
12
2016/7/912 Exercise Given the following grammar S->a|^|(T) T->T,S|S (1) Eliminate the left-recursion in the grammar. (2) Build the LL(1) parsing table
13
2016/7/913 Left-recursion Elimination
14
2016/7/914 Parsing table construction
15
2016/7/915 Parser-Bottom up parsing Right-most derivation – Backward Start with the tokens End with the start symbol Match substring on RHS of production, replace by LHS Parsing given parsing table for LR(0) Parsing table construction for LR(0) Right-associative is not LR(0)
16
2016/7/916 Parser-Bottom up parsing (2) SLR Apply reduction only if C is in FOLLOW(X) LR(1) LR(1) parsing table construction LALR Constructs LR(1) DFA and then merge any 2 LR(1) states whose items are identical except lookahead Classification of grammar
17
2016/7/917 Given the following grammar S->AS|b A->SA|a (1) Build the full LR(0) DFA (2) Is it an SLR(1) grammar?
18
2016/7/918
19
2016/7/919 For state I1, note that Follow(S ’ )={$}. Hence, the shift-reduce conflict in state I1 can be solved in SLR(1). For state I6, note that Follow(A)={a,b}. Hence, there is a shift-reduce conflict in state I6 which cannot solved in SLR(1). For state I7, note that Follow(S)={a,b,$}. Hence, there is a shift-reduce conflict in state I7 which cannot solved in SLR(1).
20
2016/7/920 Semantic Analysis Syntax-directed definition Semantic actions Synthesized attribute Inherited attribute lexical, syntax, semantic errors Symbol table construction Type derivation
21
2016/7/921 Intermediate Code Generation Translate high-level to low-level sentences 4 Distinct Regions of Memory Execution Stack Activation record/frame
22
2016/7/922 Running time organization Parameter passing modes Value Reference Value/result Name
23
2016/7/923 Parameter Passing Modes int i; int A[3]; void Q(int B) { A[1] = 3; i = 2; write(B); B = 5; } int main() { i = 1; A[1] = 2; A[2] = 4; Q(A[i]); }
24
2016/7/924 Mark Distribution DFA, Regular language and Scanner24 CFG and Parser40 Semantic Analysis19 Intermediate Code Generation5 Runtime Organization12
25
2016/7/925 Good Luck!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.